@nice2dev/ui 1.1.9 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/CHANGELOG.md +150 -0
  2. package/README.md +27 -34
  3. package/dist/NiceButton-5tWvfXKl.cjs +1 -0
  4. package/dist/NiceButton-DHSgQT1_.js +112 -0
  5. package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
  6. package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
  7. package/dist/NiceCodeEditor-BfkH1bsZ.cjs +260 -0
  8. package/dist/NiceCodeEditor-CduGYggj.js +1179 -0
  9. package/dist/NiceColorPicker-CdUnhM-A.cjs +1 -0
  10. package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
  11. package/dist/NiceColorPicker-DK30kJgy.js +486 -0
  12. package/dist/NiceColorPicker-DpXwnDwL.js +598 -0
  13. package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
  14. package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
  15. package/dist/NiceConfirmDialog-B7aNRL2K.cjs +1 -0
  16. package/dist/NiceConfirmDialog-BdhWenrO.js +81 -0
  17. package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
  18. package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
  19. package/dist/NiceDataGrid-CVYEo_nv.cjs +10 -0
  20. package/dist/NiceDataGrid-D-rm4lu8.js +2217 -0
  21. package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
  22. package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
  23. package/dist/NiceDocumentViewer-BgcgLWJ3.cjs +180 -0
  24. package/dist/NiceDocumentViewer-sukmGhRx.js +672 -0
  25. package/dist/NiceForm-BCEXovJR.cjs +1 -0
  26. package/dist/NiceForm-D7oyWHXg.js +4820 -0
  27. package/dist/NiceForm-DUhxXArr.js +4817 -0
  28. package/dist/NiceForm-DVc0Xoly.js +4819 -0
  29. package/dist/NiceForm-qD_RKPYz.cjs +1 -0
  30. package/dist/NiceForm-uCeVmTrD.cjs +1 -0
  31. package/dist/NiceGantt-4UBd4uJ8.cjs +1 -0
  32. package/dist/NiceGantt-B_1lwEsp.js +328 -0
  33. package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
  34. package/dist/NiceHtmlEditor-Bce9Vwe1.cjs +10 -0
  35. package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
  36. package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
  37. package/dist/NiceHtmlEditor-CGRgcu2h.js +848 -0
  38. package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
  39. package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
  40. package/dist/NiceLoginForm-BTuQ0eKk.cjs +1 -0
  41. package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
  42. package/dist/NiceLoginForm-o1A-TBcp.js +736 -0
  43. package/dist/NiceLoginForm.css +1 -0
  44. package/dist/NiceMention-CA7CL5BI.js +11263 -0
  45. package/dist/NiceMention-CHcKRl-L.cjs +430 -0
  46. package/dist/NiceMention-DJD0BLcp.js +11269 -0
  47. package/dist/NiceMention-DcaUEMSg.cjs +430 -0
  48. package/dist/NiceMention-Dds9GQzk.cjs +430 -0
  49. package/dist/NiceMention-DlLXWddO.js +11268 -0
  50. package/dist/NiceMention.css +1 -1
  51. package/dist/NiceModal-C4p8a82e.cjs +1 -0
  52. package/dist/NiceModal-Dr1e3nQZ.cjs +1 -0
  53. package/dist/NiceModal-TNlkaL_i.js +85 -0
  54. package/dist/NiceModal-sihGCfDy.js +95 -0
  55. package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
  56. package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
  57. package/dist/NiceModuleLifecyclePanel-Du7G3-RG.js +7053 -0
  58. package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
  59. package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
  60. package/dist/NiceModuleLifecyclePanel-js1p7LIY.cjs +1 -0
  61. package/dist/NicePagination-8XsBbMNx.js +165 -0
  62. package/dist/NicePagination-CkOoXf0f.js +165 -0
  63. package/dist/NicePagination-D44waj9o.cjs +1 -0
  64. package/dist/NicePagination-D7lek1G7.cjs +1 -0
  65. package/dist/NicePagination-DdxH8KMG.js +179 -0
  66. package/dist/NicePagination-OjTEfZJE.cjs +1 -0
  67. package/dist/NicePivotGrid-B2YHP3Z6.js +1183 -0
  68. package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
  69. package/dist/NicePivotGrid-BtVUWiud.cjs +152 -0
  70. package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
  71. package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
  72. package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
  73. package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
  74. package/dist/NiceSavedQueryPanel-C0A-eoYN.js +5142 -0
  75. package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
  76. package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
  77. package/dist/NiceSavedQueryPanel-ZrilZRtf.cjs +586 -0
  78. package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
  79. package/dist/NiceSavedQueryPanel.css +1 -1
  80. package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
  81. package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
  82. package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
  83. package/dist/NiceScheduler-KSzaUQxC.js +1693 -0
  84. package/dist/NiceScheduler-O3AwmdGG.cjs +5 -0
  85. package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
  86. package/dist/NiceSelect-BCbWtu1v.js +433 -0
  87. package/dist/NiceSelect-BqtiQbfD.cjs +1 -0
  88. package/dist/NiceSelect-DZB1Rs9x.js +435 -0
  89. package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
  90. package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
  91. package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
  92. package/dist/NiceWindow-BEov3s9F.js +2094 -0
  93. package/dist/NiceWindow-BU1Ce7gS.js +1623 -0
  94. package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
  95. package/dist/NiceWindow-jjdE6vGy.cjs +1 -0
  96. package/dist/NiceWindow.css +1 -1
  97. package/dist/charts-C047IMVn.cjs +768 -0
  98. package/dist/charts-C44vJber.cjs +768 -0
  99. package/dist/charts-CCXSb3xk.js +4752 -0
  100. package/dist/charts-CqETcUhH.js +4752 -0
  101. package/dist/charts-DouiiHOT.cjs +768 -0
  102. package/dist/charts-XVlDwU0y.js +4732 -0
  103. package/dist/charts.cjs +1 -1
  104. package/dist/charts.mjs +8 -8
  105. package/dist/core-BL-KmGYC.js +795 -0
  106. package/dist/core-BxiH7vkV.cjs +1 -0
  107. package/dist/core-Chg-oYCr.cjs +1 -0
  108. package/dist/core-CxBnKAhs.cjs +1 -0
  109. package/dist/core-DMV6_SEE.js +795 -0
  110. package/dist/core-D_LRh59n.js +795 -0
  111. package/dist/data-branching-Km4lc8P_.cjs +1 -0
  112. package/dist/data-branching-YQtJJEtn.js +6273 -0
  113. package/dist/data-branching-oEH04O3i.js +6273 -0
  114. package/dist/data-branching-wmsbLNfa.cjs +1 -0
  115. package/dist/data-branching.cjs +1 -1
  116. package/dist/data-branching.mjs +1 -1
  117. package/dist/data.cjs +1 -1
  118. package/dist/data.d.ts +2 -53
  119. package/dist/data.mjs +3 -3
  120. package/dist/devops-Bt6EsfPa.cjs +17 -0
  121. package/dist/devops-CnZQ1rU5.js +8312 -0
  122. package/dist/devops-D5yIDM3e.js +8312 -0
  123. package/dist/devops-rVpB0ZAX.cjs +17 -0
  124. package/dist/devops.cjs +1 -1
  125. package/dist/devops.mjs +1 -1
  126. package/dist/editors.cjs +1 -1
  127. package/dist/editors.d.ts +8 -26
  128. package/dist/editors.mjs +55 -54
  129. package/dist/feedback.cjs +1 -1
  130. package/dist/feedback.d.ts +5 -0
  131. package/dist/feedback.mjs +3 -3
  132. package/dist/index.cjs +290 -290
  133. package/dist/index.css +1 -1
  134. package/dist/index.d.ts +239 -234
  135. package/dist/index.mjs +20262 -19440
  136. package/dist/lazy.cjs +1 -1
  137. package/dist/lazy.mjs +29 -29
  138. package/dist/navigation.cjs +1 -1
  139. package/dist/navigation.d.ts +4 -4
  140. package/dist/navigation.mjs +69 -69
  141. package/dist/no-code-4GtIBr6f.js +7503 -0
  142. package/dist/no-code-6WyYb3hL.cjs +331 -0
  143. package/dist/no-code-BH5oVFC6.js +8186 -0
  144. package/dist/no-code-Bdwh1vyS.cjs +332 -0
  145. package/dist/no-code-CnHG5_Vn.js +8186 -0
  146. package/dist/no-code-DMKlg1Zl.cjs +331 -0
  147. package/dist/no-code.cjs +1 -1
  148. package/dist/no-code.css +1 -1
  149. package/dist/no-code.d.ts +25 -18
  150. package/dist/no-code.mjs +3 -3
  151. package/dist/overlays.cjs +1 -1
  152. package/dist/overlays.d.ts +24 -24
  153. package/dist/overlays.mjs +24 -490
  154. package/dist/pickerCommons-0vyK1Knv.js +547 -0
  155. package/dist/pickerCommons-31hyz1gs.js +1122 -0
  156. package/dist/pickerCommons-BFbItm8o.cjs +1 -0
  157. package/dist/pickerCommons-BHirHJyn.js +548 -0
  158. package/dist/pickerCommons-BifIkPdk.cjs +1 -0
  159. package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
  160. package/dist/pickerCommons.css +1 -1
  161. package/dist/style.css +10 -7
  162. package/package.json +5 -7
  163. package/css/legacy-bg-text-aliases.css +0 -87
@@ -0,0 +1,430 @@
1
+ "use strict";const e=require("react/jsx-runtime"),u=require("@nice2dev/ui-core"),n=require("react"),Qe=require("react-dom"),Be=require("./NiceSelect-tMz9QQUs.cjs"),rt=require("./NiceForm-uCeVmTrD.cjs"),Zt=require("./pickerCommons-Bt8JIaTN.cjs"),Ze=require("./no-code-DMKlg1Zl.cjs"),Qt=require("@nice2dev/i18n"),Xn=require("./NiceHtmlEditor-C5kLeF9H.cjs"),Se=require("./NiceColorPicker-DCgmE-3H.cjs"),_t=require("./NiceCodeEditor-BfkH1bsZ.cjs"),en=require("./devops-Bt6EsfPa.cjs"),qn=({min:t=0,max:i=100,step:a=1,startValue:o=t,endValue:r=i,onChange:g,showLabels:x=!0,formatLabel:v,valuePlacement:D="none",label:N,error:q,helperText:G,required:P,disabled:_,readOnly:J,loading:ie,size:ee="md",id:ae,className:R,style:j,accessMode:I,showKeyboardHints:p,labelPlacement:w,errorPlacement:X,labelWidth:h,controlWidth:f})=>{const B=u.useNiceAccessMode(I,ae),te=B==="hidden";(B==="disabled"||B==="readOnly")&&(_=!0);const{t:M}=u.useNiceTranslation(),y=u.useControlId(ae),s=n.useRef(null),E=n.useMemo(()=>[u.COMMON_SHORTCUTS.increment,u.COMMON_SHORTCUTS.decrement,u.COMMON_SHORTCUTS.first,u.COMMON_SHORTCUTS.last,{key:"Tab",description:M("shortcuts.switchThumb","Switch thumb")}],[M]),L=b=>(b-t)/(i-t)*100,l=b=>v?v(b):String(b),c=b=>{const z=Math.round(b/a)*a;return Math.max(t,Math.min(i,z))},d=n.useCallback((b,z)=>{b.preventDefault();const $=s.current;if(!$||_)return;const C=T=>{const k=$.getBoundingClientRect(),A=Math.max(0,Math.min(1,(T.clientX-k.left)/k.width)),O=c(t+A*(i-t));z==="start"?g?.(Math.min(O,r),r):g?.(o,Math.max(O,o))},S=()=>{document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",S)};document.addEventListener("pointermove",C),document.addEventListener("pointerup",S)},[t,i,a,o,r,g,_]);return te?null:e.jsxs("div",{className:`nice-field nice-field--${ee} nice-field--rangeslider ${w==="left"?"nice-field--label-left":""} ${X==="right"?"nice-field--error-right":""} ${q?"nice-field--error":""} ${ie?"nice-field--loading":""} ${R||""}`,style:{...j,...h!=null&&{"--nice-field-label-width":typeof h=="number"?`${h}px`:h},...f!=null&&{"--nice-field-control-width":typeof f=="number"?`${f}px`:f}},"aria-busy":ie||void 0,children:[(N||D==="right"&&w!=="left")&&(w!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[N?e.jsx("label",{className:"nice-field__label",htmlFor:y,children:e.jsxs("span",{className:"nice-field__label-text",children:[N,P&&e.jsx("span",{className:"nice-field__required",children:"*"}),p&&e.jsx(u.NiceKeyboardHint,{shortcuts:E,size:"sm"})]})}):e.jsx("span",{}),D==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[l(o)," – ",l(r)]})]}):N&&e.jsx("label",{className:"nice-field__label",htmlFor:y,children:e.jsxs("span",{className:"nice-field__label-text",children:[N,P&&e.jsx("span",{className:"nice-field__required",children:"*"}),p&&e.jsx(u.NiceKeyboardHint,{shortcuts:E,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${x?"nice-range-slider--with-labels":""} ${N?"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:`${L(o)}%`,width:`${L(r)-L(o)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${L(o)}%`},onPointerDown:b=>J?void 0:d(b,"start"),role:"slider","aria-valuemin":t,"aria-valuemax":r,"aria-valuenow":o,tabIndex:_?-1:0,id:y}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${L(r)}%`},onPointerDown:b=>J?void 0:d(b,"end"),role:"slider","aria-valuemin":o,"aria-valuemax":i,"aria-valuenow":r,tabIndex:_?-1:0})]}),x&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${L(o)}%`},children:l(o)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${L(r)}%`},children:l(r)})]}),D==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[l(o)," – ",l(r)]})]}),D==="right"&&w==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[l(o)," – ",l(r)]}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),X==="right"&&q&&e.jsx("div",{className:"nice-field__error",role:"alert",children:q}),X==="right"&&!q&&G&&e.jsx("div",{className:"nice-field__helper",children:G})]}),X!=="right"&&q&&e.jsx("div",{className:"nice-field__error",role:"alert",children:q}),X!=="right"&&!q&&G&&e.jsx("div",{className:"nice-field__helper",children:G})]})},Gn={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},ct=6,at=135,tn=405,it=tn-at;function kt(t,i,a,o){const r=(o-90)*(Math.PI/180);return{x:t+a*Math.cos(r),y:i+a*Math.sin(r)}}function Tt(t,i,a,o,r){const g=kt(t,i,a,o),x=kt(t,i,a,r),v=r-o>180?1:0;return`M ${g.x} ${g.y} A ${a} ${a} 0 ${v} 1 ${x.x} ${x.y}`}const nn=n.forwardRef(({value:t=0,onChange:i,min:a=0,max:o=100,step:r=1,showValue:g=!0,valueTemplate:x="{value}",label:v,helperText:D,error:N,required:q,disabled:G,readOnly:P,size:_="md",name:J,id:ie,className:ee,style:ae,labelPlacement:R="top",errorPlacement:j,labelWidth:I,controlWidth:p,loading:w,isLabelCentered:X=!0,...h},f)=>{const B=u.useControlId(ie),te=n.useRef(!1),M=n.useRef(null),y=typeof _=="number"?_:Gn[_],s=y/2,E=y/2,L=(y-ct*2)/2,l=o>a?(t-a)/(o-a):0,c=at+l*it,d=n.useCallback(S=>{let T=S-at;T<0&&(T+=360),T>it&&(T=T-it<360-T?it:0);const k=Math.max(0,Math.min(1,T/it)),A=a+k*(o-a),O=Math.round(A/r)*r;return Math.max(a,Math.min(o,O))},[a,o,r]),b=n.useCallback(S=>{if(G||P)return;const T=M.current;if(!T)return;const k=T.getBoundingClientRect(),A=S.clientX-k.left-k.width/2,O=S.clientY-k.top-k.height/2;let ce=Math.atan2(A,-O)*(180/Math.PI);ce<0&&(ce+=360);const pe=d(ce);i?.(pe)},[d,G,P,i]);n.useEffect(()=>{const S=k=>{te.current&&b(k)},T=()=>{te.current=!1};return window.addEventListener("pointermove",S),window.addEventListener("pointerup",T),()=>{window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",T)}},[b]);const z=n.useCallback(S=>{if(G||P)return;let T=t;S.key==="ArrowUp"||S.key==="ArrowRight"?(S.preventDefault(),T=Math.min(o,t+r)):(S.key==="ArrowDown"||S.key==="ArrowLeft")&&(S.preventDefault(),T=Math.max(a,t-r)),T!==t&&i?.(T)},[t,i,a,o,r,G,P]),$=(x||"{value}").replace("{value}",String(t)),C=kt(s,E,L,c);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${j||"bottom"} nice-field--${typeof _=="string"?_:"md"} ${w?"nice-field--loading":""} ${ee||""}`,style:{...ae,...I!=null&&{"--nice-field-label-width":typeof I=="number"?`${I}px`:I},...p!=null&&{"--nice-field-control-width":typeof p=="number"?`${p}px`:p}},"aria-busy":w||void 0,...h,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${R} ${X?"nice-knob-field--label-centered":""}`,children:[v&&e.jsx("label",{htmlFor:B,className:`nice-field__label ${q?"nice-field__label--required":""}`,children:v}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:S=>{M.current=S,typeof f=="function"?f(S):f&&(f.current=S)},className:`nice-knob nice-knob--${_} ${G?"nice-knob--disabled":""} ${N?"nice-knob--error":""}`,role:"slider",id:B,tabIndex:G?-1:0,"aria-valuenow":t,"aria-valuemin":a,"aria-valuemax":o,"aria-disabled":G,"aria-invalid":!!N,onPointerDown:S=>{G||P||(te.current=!0,b(S))},onKeyDown:z,children:[e.jsxs("svg",{width:y,height:y,viewBox:`0 0 ${y} ${y}`,children:[e.jsx("path",{d:Tt(s,E,L,at,tn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ct,strokeLinecap:"round"}),l>0&&e.jsx("path",{d:Tt(s,E,L,at,c),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:ct,strokeLinecap:"round"}),e.jsx("circle",{cx:C.x,cy:C.y,r:ct,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:$}),J&&e.jsx("input",{type:"hidden",name:J,value:t}),w&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),N&&e.jsx("div",{className:"nice-field__error",role:"alert",children:N}),!N&&D&&e.jsx("div",{className:"nice-field__helper",children:D})]})});nn.displayName="NiceKnob";function Vn(t,{open:i,onSelect:a,onClose:o,onOpen:r,loop:g=!1}){const[x,v]=n.useState(0);n.useEffect(()=>{v(N=>t.length===0?0:Math.min(Math.max(N,0),t.length-1))},[t.length]);const D=n.useCallback(N=>{if(!i){(N.key==="ArrowDown"||N.key==="ArrowUp")&&(N.preventDefault(),r?.());return}if(N.key==="ArrowDown")N.preventDefault(),v(q=>t.length===0?0:g?(q+1)%t.length:Math.min(q+1,t.length-1));else if(N.key==="ArrowUp")N.preventDefault(),v(q=>t.length===0?0:g?(q-1+t.length)%t.length:Math.max(q-1,0));else if(N.key==="Enter"){const q=t[x];q!==void 0&&(N.preventDefault(),a(q,x))}else N.key==="Escape"&&o?.()},[i,t,x,g,a,o,r]);return{activeIndex:x,setActiveIndex:v,handleKeyDown:D}}const Wn=({options:t,value:i,defaultValue:a,onChange:o,searchable:r=!0,clearable:g,loading:x,placeholder:v,label:D,error:N,helperText:q,required:G,disabled:P,readOnly:_,size:J="md",id:ie,className:ee,style:ae,data:R,columns:j,valueField:I="id",displayField:p,dropdownWidth:w,menuGap:X,labelPlacement:h,errorPlacement:f,labelWidth:B,controlWidth:te})=>{const M=P||_||x,y=u.useControlId(ie),{t:s}=u.useNiceTranslation(),[E,L]=u.useControllableState({value:i,defaultValue:a,fallbackValue:"",onChange:o,componentName:"NiceLookup"}),[l,c]=n.useState(!1),[d,b]=n.useState(""),z=n.useRef(null),$=n.useRef(null),{popupRef:C,coords:S,ready:T,themeClass:k,portalTarget:A}=Be.useAnchoredPopup(l,$,()=>c(!1)),O=!!(R&&j&&j.length>0),ce=p??(j&&j[0]?.key),pe=n.useMemo(()=>!O||!R?[]:R.map(Q=>({value:String(Q[I]??""),label:ce?String(Q[ce]??""):""})),[O,R,I,ce]),ne=O?pe:t??[],je=ne.find(Q=>String(Q.value)===E),ve=n.useMemo(()=>{if(!O||!R)return[];if(!d)return R;const Q=d.toLowerCase();return R.filter(de=>j.some(F=>String(de[F.key]??"").toLowerCase().includes(Q)))},[O,R,j,d]),_e=n.useMemo(()=>{if(O||!d)return ne;const Q=d.toLowerCase();return ne.filter(de=>de.label.toLowerCase().includes(Q))},[ne,d,O]),he=O?ve:_e,{activeIndex:ye,setActiveIndex:xe,handleKeyDown:re}=Vn(he,{open:l,onSelect:Q=>{const de=String(O?Q[I]??"":Q.value);L(de),c(!1),b("")},onClose:()=>c(!1)});return e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${J} ${N?"nice-field--error":""} ${h==="left"?"nice-field--label-left":""} ${f==="right"&&(N||q)?"nice-field--error-right":""} ${x?"nice-field--loading":""} ${P?"nice-field--disabled":""} ${ee||""}`,style:{...te!=null&&{"--nice-field-control-width":typeof te=="number"?`${te}px`:te},...B!=null&&{"--nice-field-label-width":typeof B=="number"?`${B}px`:B},...X!=null&&{"--nice-dropdown-gap":`${X}px`},...ae},"aria-busy":x||void 0,ref:z,children:[D&&e.jsxs("label",{className:"nice-field__label",htmlFor:y,children:[D,G&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-field__input-wrap",ref:$,children:[e.jsxs("button",{type:"button",id:y,className:`nice-select__trigger ${P?"nice-select__trigger--disabled":""}`,onClick:()=>!M&&c(!l),disabled:P,"aria-readonly":_||void 0,"aria-expanded":l,children:[e.jsx("span",{children:je?.label||v||s("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[g&&E&&!P&&!_&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":s("controls.clear","Clear"),onClick:Q=>{Q.stopPropagation(),L("")},children:e.jsx(u.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${_?" nice-select__arrow--hidden":""}`,children:e.jsx(u.NiceIcon,{name:"chevron-down",size:16})})]})]}),l&&S&&A&&Qe.createPortal(e.jsxs("div",{ref:C,className:`nice-dropdown nice-lookup__dropdown${k?` ${k}`:""}`,"data-theme":k==="nice-dark"?"dark":k==="nice-light"?"light":void 0,style:{position:"fixed",top:S.top,left:S.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:S.width,width:w!=null?typeof w=="number"?`${w}px`:w:O?"max-content":S.width,opacity:T?1:0,pointerEvents:T?void 0:"none"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:d,onChange:Q=>{b(Q.target.value),xe(0)},onKeyDown:re,placeholder:s("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),O?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:j.map(Q=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:Q.width!=null?typeof Q.width=="number"?`${Q.width}px`:Q.width:void 0},children:Q.header},Q.key))})}),e.jsx("tbody",{children:ve.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:j.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:s("controls.noResults","No results")})}):ve.map((Q,de)=>{const F=String(Q[I]??""),H=F===E,U=de===ye;return e.jsx("tr",{role:"option","aria-selected":H,onClick:()=>{L(F),c(!1),b("")},style:{cursor:"pointer",background:H||U?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>xe(de),children:j.map(ge=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(Q[ge.key]??"")},ge.key))},F)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:_e.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:s("controls.noResults","No results")}):_e.map((Q,de)=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(Q.value)===E?"nice-dropdown__option--selected":""} ${de===ye?"nice-dropdown__option--active":""}`,onClick:()=>{L(String(Q.value)),c(!1),b("")},onMouseEnter:()=>xe(de),"aria-selected":String(Q.value)===E,children:Q.label},String(Q.value)))})]}),A)]}),x&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),f==="right"&&N&&e.jsx("div",{className:"nice-field__error",role:"alert",children:N}),f==="right"&&!N&&q&&e.jsx("div",{className:"nice-field__hint",children:q})]}),f!=="right"&&N&&e.jsx("div",{className:"nice-field__error",children:N}),f!=="right"&&!N&&q&&e.jsx("div",{className:"nice-field__hint",children:q})]})};function Jn(t){const i=[],a=o=>{for(const r of o)i.push(r),r.children&&a(r.children)};return a(t),i}function an(t,i){const a=i.toLowerCase();return t.reduce((o,r)=>{const g=r.children?an(r.children,i):[];return(r.label.toLowerCase().includes(a)||g.length>0)&&o.push({...r,children:g.length>0?g:r.children}),o},[])}const on=({node:t,level:i,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:g,selectableLeafsOnly:x,maxDepth:v})=>{const D=typeof v=="number"?Math.min(10,Math.max(1,v)):1/0,q=!(i+1>=D)&&t.children&&t.children.length>0,G=o.has(t.key),P=a.has(t.key),_=!q,J=!t.disabled&&(!x||_),ie=Math.min(i+1,10),ee={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${ie}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ie}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ie}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${ie}-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 ${P?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ee,"data-nice-depth":ie,onClick:()=>{t.disabled||(q?r(t.key):J&&g(t.key))},role:"treeitem","aria-selected":P,"aria-expanded":q?G:void 0,"aria-disabled":t.disabled,children:[q?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",onClick:ae=>{ae.stopPropagation(),r(t.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:G?"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})]}),q&&G&&t.children.map(ae=>e.jsx(on,{node:ae,level:i+1,selectedKeys:a,expandedKeys:o,onToggleExpand:r,onSelect:g,selectableLeafsOnly:x,maxDepth:v},ae.key))]})},sn=n.forwardRef(({nodes:t,value:i,onChange:a,multiple:o=!1,searchable:r=!1,placeholder:g,selectableLeafsOnly:x=!1,clearable:v=!1,maxDepth:D,label:N,helperText:q,error:G,required:P,disabled:_,readOnly:J,size:ie="md",name:ee,id:ae,className:R,style:j,controlWidth:I,menuGap:p,labelPlacement:w,errorPlacement:X,labelWidth:h,...f},B)=>{const{t:te}=u.useNiceTranslation(),M=u.useControlId(ae),[y,s]=n.useState(!1),[E,L]=n.useState(""),[l,c]=n.useState(new Set),d=n.useRef(null),{popupRef:b,coords:z,ready:$,themeClass:C,portalTarget:S}=Be.useAnchoredPopup(y,d,()=>s(!1)),T=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),k=n.useMemo(()=>E?an(t,E):t,[t,E]),A=n.useMemo(()=>{const ne=Jn(t);return Array.from(T).map(je=>ne.find(ve=>ve.key===je)?.label).filter(Boolean)},[T,t]),O=n.useCallback(ne=>{c(je=>{const ve=new Set(je);return ve.has(ne)?ve.delete(ne):ve.add(ne),ve})},[]),ce=n.useCallback(ne=>{if(o){const je=new Set(T);je.has(ne)?je.delete(ne):je.add(ne),a?.(Array.from(je))}else a?.(ne),s(!1)},[o,T,a]),pe=n.useCallback(ne=>{ne.stopPropagation(),a?.(o?[]:"")},[a,o]);return e.jsxs("div",{className:`nice-field nice-field--${ie}${w?` nice-field--label-${w}`:""}${X==="right"?" nice-field--error-right":""} ${R||""}`,style:{width:"fit-content",maxWidth:"100%",...p!=null&&{"--nice-dropdown-gap":`${p}px`},...h!=null&&{"--nice-field-label-width":typeof h=="number"?`${h}px`:h},...j},...f,children:[N&&e.jsx("label",{htmlFor:M,className:`nice-field__label ${P?"nice-field__label--required":""}`,children:N}),e.jsxs("div",{ref:d,className:"nice-tree-select",style:{position:"relative",width:I!=null&&I!==""?typeof I=="number"?`${I}px`:I:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:B,id:M,className:`nice-input nice-input--${ie} ${G?"nice-input--error":""} ${_?"nice-input--disabled":""} ${J?"nice-input--readonly":""}`,role:"combobox","aria-expanded":y,"aria-haspopup":"tree","aria-invalid":!!G,tabIndex:_?-1:0,onClick:()=>!_&&!J&&s(!y),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),!_&&!J&&s(!y))},children:[e.jsx("span",{className:"nice-tree-select__display",children:A.length>0?A.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??te("controls.select","Select...")})}),v&&T.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:pe,"aria-label":te("controls.clear","Clear"),children:e.jsx(u.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:y?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(u.NiceIcon,{name:"chevron-down",size:14})})]}),y&&z&&S&&Qe.createPortal(e.jsxs("div",{ref:b,className:`nice-tree-select__dropdown${C?` ${C}`:""}`,"data-theme":C==="nice-dark"?"dark":C==="nice-light"?"light":void 0,role:"tree",style:{position:"fixed",left:z.left,top:z.top,width:z.width,minWidth:z.width,zIndex:1e3,opacity:$?1:0,pointerEvents:$?void 0:"none"},children:[r&&e.jsx("div",{className:"nice-select__search",onClick:ne=>ne.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:te("controls.search","Search..."),value:E,onChange:ne=>L(ne.target.value),autoFocus:!0})}),e.jsx("div",{className:"nice-tree-select__list",children:k.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:te("controls.noResults","No results")}):k.map(ne=>e.jsx(on,{node:ne,level:0,selectedKeys:T,expandedKeys:l,onToggleExpand:O,onSelect:ce,selectableLeafsOnly:x,maxDepth:D},ne.key))})]}),S)]}),ee&&e.jsx("input",{type:"hidden",name:ee,value:Array.isArray(i)?i.join(","):i??""}),G&&e.jsx("div",{id:`${M}-error`,className:"nice-field__error",role:"alert",children:G}),!G&&q&&e.jsx("div",{id:`${M}-helper`,className:"nice-field__helper",children:q})]})});sn.displayName="NiceTreeSelect";const Zn=({displayValue:t,placeholder:i,clearable:a,children:o,onClear:r,open:g,onOpenChange:x,dropdownWidth:v,searchable:D=!0,onSearch:N,searchPlaceholder:q,label:G,error:P,helperText:_,required:J,disabled:ie,size:ee="md",id:ae,className:R,style:j,accessMode:I,showKeyboardHints:p,displayStyle:w})=>{u.useComponentDisplayStyle("input",w),u.useComponentDisplayClass("input",w);const X=u.useNiceAccessMode(I,ae),h=X==="hidden";(X==="disabled"||X==="readOnly")&&(ie=!0);const f=u.useControlId(ae),{t:B}=u.useNiceTranslation(),[te,M]=n.useState(!1),[y,s]=n.useState(""),E=n.useRef(null),L=n.useRef(null),l=g??te,c=n.useMemo(()=>[{key:"Enter",description:B("shortcuts.openDropdown","Open dropdown")},u.COMMON_SHORTCUTS.cancel],[B]),d=T=>{x?x(T):M(T)},{popupRef:b,coords:z,ready:$,themeClass:C,portalTarget:S}=Be.useAnchoredPopup(l,L,()=>d(!1));return h?null:e.jsxs("div",{className:`nice-field nice-field--${ee} ${P?"nice-field--error":""} ${R||""}`,style:j,ref:E,children:[G&&e.jsxs("label",{className:"nice-field__label",htmlFor:f,children:[G,J&&e.jsx("span",{className:"nice-field__required",children:"*"}),p&&e.jsx(u.NiceKeyboardHint,{shortcuts:c,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:L,children:[e.jsxs("button",{type:"button",id:f,className:"nice-select__trigger",onClick:()=>!ie&&d(!l),disabled:ie,children:[e.jsx("span",{children:t||i||B("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[a&&t&&!ie&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":B("controls.clear","Clear"),onClick:T=>{T.stopPropagation(),r?.()},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r?.())},children:e.jsx(u.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(u.NiceIcon,{name:"chevron-down",size:16})})]})]}),l&&z&&S&&Qe.createPortal(e.jsxs("div",{ref:b,className:`nice-dropdown${C?` ${C}`:""}`,"data-theme":C==="nice-dark"?"dark":C==="nice-light"?"light":void 0,style:{position:"fixed",left:z.left,top:z.top,width:v??z.width,minWidth:v??z.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:$?1:0,pointerEvents:$?void 0:"none"},children:[D&&N&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:y,onChange:T=>{s(T.target.value),N(T.target.value)},placeholder:q??B("controls.search","Search..."),autoFocus:!0})}),o]}),S)]}),P&&e.jsx("div",{className:"nice-field__error",children:P}),_&&!P&&e.jsx("div",{className:"nice-field__hint",children:_})]})};function Xe(t,i){return String(t[i])}const Qn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},rn=n.forwardRef(({source:t,target:i,onChange:a,keyField:o="id",labelField:r="label",renderItem:g,filterable:x=!1,searchable:v,groupBy:D,sortable:N=!1,bulkActions:q=!0,maxRight:G,sourceHeader:P,targetHeader:_,disabled:J=!1,size:ie="md",className:ee,style:ae,id:R,...j},I)=>{const{t:p}=u.useNiceTranslation(),w=Qn[ie]??14,[X,h]=n.useState(new Set),[f,B]=n.useState(new Set),[te,M]=n.useState(""),[y,s]=n.useState(""),[E,L]=n.useState(null),l=n.useCallback((T,k,A)=>{k(O=>{const ce=new Set(O);return ce.has(A)?ce.delete(A):ce.add(A),ce})},[]),c=n.useCallback(()=>{const T=t.filter(ce=>X.has(Xe(ce,o))),k=t.filter(ce=>!X.has(Xe(ce,o))),A=typeof G=="number"?T.slice(0,Math.max(0,G-i.length)):T,O=T.slice(A.length);a([...k,...O],[...i,...A]),h(new Set)},[t,i,X,o,a,G]),d=n.useCallback(()=>{const T=i.filter(A=>f.has(Xe(A,o))),k=i.filter(A=>!f.has(Xe(A,o)));a([...t,...T],k),B(new Set)},[t,i,f,o,a]),b=n.useCallback(()=>{if(typeof G=="number"){const T=Math.max(0,G-i.length),k=t.slice(0,T),A=t.slice(T);a(A,[...i,...k])}else a([],[...i,...t]);h(new Set)},[t,i,a,G]),z=n.useCallback(()=>{a([...t,...i],[]),B(new Set)},[t,i,a]),$=(T,k)=>{if(!k)return T;const A=k.toLowerCase();return T.filter(O=>String(O[r]).toLowerCase().includes(A))},C=q===!1?{moveAll:!1,removeAll:!1}:q===!0||q===void 0?{moveAll:!0,removeAll:!0}:{moveAll:q.moveAll??!0,removeAll:q.removeAll??!0},S=(T,k,A,O,ce,pe,ne)=>{let je=$(T,O);N||(je=[...je].sort((Q,de)=>String(Q[r]).localeCompare(String(de[r]),void 0,{numeric:!0,sensitivity:"base"})));const ve=v===!0||x&&v===void 0?"both":v??!1,_e=ve==="both"||ve==="left"&&ne==="left"||ve==="right"&&ne==="right",he=(()=>{if(!D)return[{label:"",items:je}];const Q=new Map;for(const de of je){const F=String(D(de));let H=Q.get(F);H||(H=[],Q.set(F,H)),H.push(de)}return[...Q.entries()].map(([de,F])=>({label:de,items:F}))})(),ye=(Q,de)=>{Q.dataTransfer.setData("text/plain",de),Q.dataTransfer.effectAllowed="move"},xe=(Q,de)=>{if(Q.preventDefault(),!N)return;const F=Q.currentTarget.getBoundingClientRect(),H=Q.clientY<F.top+F.height/2;L(U=>U&&U.side===ne&&U.key===de&&U.before===H?U:{side:ne,key:de,before:H})},re=(Q,de)=>{Q.preventDefault();const F=E?.before??!1;L(null);const H=Q.dataTransfer.getData("text/plain");if(!H||!N)return;const ge=[...ne==="right"?i:t],le=ge.findIndex(oe=>Xe(oe,o)===H),K=ge.findIndex(oe=>Xe(oe,o)===de);if(le===-1||K===-1||H===de)return;let Z=F?K:K+1;const[Y]=ge.splice(le,1);le<Z&&(Z-=1),ge.splice(Z,0,Y),a(ne==="right"?t:ge,ne==="right"?ge:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[pe&&e.jsx("div",{className:"nice-picklist__header",children:pe}),_e&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:p("controls.search","Search..."),value:O,onChange:Q=>ce(Q.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[he.map(Q=>e.jsxs(n.Fragment,{children:[Q.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:Q.label}),Q.items.map(de=>{const F=Xe(de,o),H=k.has(F),ge=E&&E.side===ne&&E.key===F?E.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${H?"nice-picklist__item--selected":""} ${ge}`,role:"option","aria-selected":H,draggable:N,onDragStart:N?le=>ye(le,F):void 0,onDragOver:N?le=>xe(le,F):void 0,onDrop:N?le=>re(le,F):void 0,onDragEnd:N?()=>L(null):void 0,onClick:()=>!J&&l(k,A,F),children:[N&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("circle",{cx:"7",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"10",r:"1.5"}),e.jsx("circle",{cx:"7",cy:"15",r:"1.5"}),e.jsx("circle",{cx:"13",cy:"15",r:"1.5"})]})}),g?g(de,ne):String(de[r])]},F)})]},Q.label||"__none__")),je.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:p("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:I,id:R,className:`nice-picklist nice-picklist--${ie} ${J?"nice-picklist--disabled":""} ${ee||""}`,style:ae,...j,children:[S(t,X,h,te,M,P??p("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--${ie}`,disabled:J||X.size===0,onClick:c,"aria-label":p("picklist.moveRight","Move right"),children:e.jsx("svg",{width:w,height:w,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"})})}),C.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:J||t.length===0,onClick:b,"aria-label":p("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:w,height:w,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--${ie}`,disabled:J||f.size===0,onClick:d,"aria-label":p("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:w,height:w,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"})})}),C.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${ie}`,disabled:J||i.length===0,onClick:z,"aria-label":p("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:w,height:w,viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M15.707 5.293a1 1 0 010 1.414L12.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"}),e.jsx("path",{d:"M9.707 5.293a1 1 0 010 1.414L6.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})]})})]}),S(i,f,B,y,s,_??p("picklist.target","Selected"),"right")]})});rn.displayName="NicePickList";function Ct(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function ei(t){const i=new Date,a=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,o=Ct(t);return o==="datetime"?`${a}T00:00`:o==="month"?a.slice(0,7):a}function Rt(t,i){if(!t)return t;const a=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(a.getTime()))return t;a.setDate(a.getDate()+i);const o=`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`;return t.length<=10?o.slice(0,t.length):o+t.slice(10)}function lt(...t){return t.filter(Boolean).sort().pop()}function jt(t,i,a){if(!t)return"";const o=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(o.getTime()))return t;const r=Ct(a);return r==="month"?o.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):r==="datetime"?o.toLocaleString(i,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"})}function At(t){let i=0;for(const a of t)i+=/[\p{L}\p{N}]/u.test(a)?1:.5;return i}const ti=({startDate:t,endDate:i,defaultStartDate:a,defaultEndDate:o,onStartChange:r,onEndChange:g,min:x,max:v,clearable:D,startPlaceholder:N,endPlaceholder:q,startLabel:G,endLabel:P,layout:_="horizontal",separator:J="–",gap:ie=12,fullWidth:ee=!1,dateFormatPreset:ae,locale:R,timeSelectorType:j,type:I,endCondition:p="greater-or-equal",startCondition:w="today-or-greater",singleField:X=!1,label:h,error:f,helperText:B,required:te,disabled:M,size:y="md",id:s,className:E,style:L,accessMode:l,showKeyboardHints:c,labelPlacement:d,errorPlacement:b,labelWidth:z,controlWidth:$,loading:C,readOnly:S})=>{const T=u.useNiceAccessMode(l,s),k=u.useControlId(s),{t:A}=u.useNiceTranslation(),O=T==="disabled"||T==="readOnly"||!!M,[ce,pe]=u.useControllableState({value:t,defaultValue:a,fallbackValue:"",onChange:r,componentName:"NiceDateRangeBox"}),[ne,je]=u.useControllableState({value:i,defaultValue:o,fallbackValue:"",onChange:g,componentName:"NiceDateRangeBox"}),ve=n.useMemo(()=>[{key:"Tab",description:A("shortcuts.switchField","Switch between start/end")},u.COMMON_SHORTCUTS.cancel],[A]),_e=n.useRef(null),he=n.useRef(null),[ye,xe]=n.useState(!1),[re,Q]=n.useState(null),[de,F]=n.useState(""),U=n.useContext(u.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null);n.useLayoutEffect(()=>{if(!ye)return;const ue=_e.current?.getBoundingClientRect();ue&&(Q({left:ue.left,top:ue.bottom+6}),F(Be.scopeThemeClass(_e.current)))},[ye]),n.useEffect(()=>{if(!ye)return;const ue=m=>{const V=m.target;_e.current?.contains(V)||he.current?.contains(V)||xe(!1)},Ie=m=>{m.key==="Escape"&&xe(!1)},Ae=()=>{const m=_e.current?.getBoundingClientRect();m&&Q({left:m.left,top:m.bottom+6})};return document.addEventListener("mousedown",ue),document.addEventListener("keydown",Ie),window.addEventListener("scroll",Ae,!0),window.addEventListener("resize",Ae),()=>{document.removeEventListener("mousedown",ue),document.removeEventListener("keydown",Ie),window.removeEventListener("scroll",Ae,!0),window.removeEventListener("resize",Ae)}},[ye]);const ge=ei(ae),le=w==="today-or-greater"?lt(x,ge):w==="greater-than-today"?lt(x,Rt(ge,1)):x,K=p==="greater-or-equal"?lt(x,ce):p==="greater"?lt(x,ce?Rt(ce,1):void 0):x,Z=n.useMemo(()=>{if(f)return f;if(ce&&ne){if(p==="greater-or-equal"&&ne<ce)return A("daterange.endBeforeStart","End date must be on or after the start date");if(p==="greater"&&ne<=ce)return A("daterange.endAfterStart","End date must be after the start date")}if(ce){if(w==="today-or-greater"&&ce<ge)return A("daterange.startInPast","Start date cannot be in the past");if(w==="greater-than-today"&&ce<=ge)return A("daterange.startAfterToday","Start date must be after today")}},[f,ce,ne,w,p,ge,A]);if(T==="hidden")return null;const Y=ue=>{pe(ue),ue&&ne&&ue>ne&&je(ue)},oe=_==="horizontal",me=Ct(ae),be=R||rt.getDefaultLocale(),we=typeof J=="string"&&J!==""?J:"–",Me=jt(ce,be,ae),Te=jt(ne,be,ae),Oe=Me||Te?`${Me||"…"} ${we} ${Te||"…"}`:"",qe=(()=>{const ue=jt("2026-12-30T22:58",be,ae),Ie=`${ue} ${we} ${ue}`;return`${(Math.max(At(Ie),At(Oe))+1.5).toFixed(1)}ch`})(),Fe=(ue,Ie)=>me==="datetime"?Ie&&Ie.length>10?`${ue}${Ie.slice(10)}`:`${ue}T00:00`:me==="month"?ue.slice(0,7):ue,Ke=({start:ue,end:Ie})=>{pe(ue?Fe(ue,ce):""),je(Ie?Fe(Ie,ne):""),ue&&Ie&&xe(!1)},Ge=()=>{pe(""),je("")},Ne=()=>{!O&&!S&&xe(ue=>!ue)},ze=ue=>ue&&ue.length>=10?ue.slice(0,10):ue||void 0;return e.jsxs("div",{className:`nice-field nice-field--${y} nice-daterange nice-daterange--${_} ${d==="left"?"nice-field--label-left":""} ${Z?"nice-field--error":""} ${C?"nice-field--loading":""} ${E||""}`,style:{...L,...z!=null&&{"--nice-field-label-width":typeof z=="number"?`${z}px`:z},...$!=null&&{"--nice-field-control-width":typeof $=="number"?`${$}px`:$}},"aria-busy":C||void 0,children:[h&&e.jsxs("label",{className:"nice-field__label",htmlFor:k,children:[h,te&&e.jsx("span",{className:"nice-field__required",children:"*"}),c&&e.jsx(u.NiceKeyboardHint,{shortcuts:ve,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[X?e.jsxs("div",{ref:_e,className:`nice-input nice-input--date nice-input--${y} nice-daterange__single ${Z?"nice-input--error":""} ${O?"nice-input--disabled":""} ${S?"nice-input--readonly":""}`,style:{position:"relative",width:ee?"100%":"fit-content"},children:[e.jsx("input",{id:k,className:"nice-input__native",type:"text",readOnly:!0,value:Oe,placeholder:N||A("controls.startDate","Start date"),disabled:O||C,autoComplete:"off","aria-invalid":!!Z,"aria-label":h?void 0:A("controls.startDate","Start date"),onClick:Ne,style:{width:ee?"100%":qe,cursor:O||S?void 0:"pointer"}}),D&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Ge,disabled:!ce&&!ne||O||S,"aria-label":A("controls.clear","Clear"),tabIndex:(ce||ne)&&!O&&!S?0:-1,children:e.jsx(u.NiceIcon,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:Ne,"aria-label":A("controls.openPicker","Open picker"),"aria-expanded":ye,tabIndex:-1,disabled:O||S,children:e.jsx(u.NiceIcon,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:oe?"row":"column",alignItems:oe?d==="left"?"center":"flex-end":"stretch",gap:ie,flexWrap:oe?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{id:k,dateFormatPreset:ae,displayLocale:R,timeSelectorType:j,type:I,label:G,value:ce,onChange:Y,min:le,max:ne||v,placeholder:N||A("controls.startDate","Start date"),disabled:O,readOnly:S,size:y,clearable:D,labelPlacement:d,labelWidth:z})}),oe&&J!==""&&J!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:J}),e.jsx("div",{style:{flex:ee?"1 1 0":void 0,minWidth:0},children:e.jsx(rt.NiceDateTimePicker,{dateFormatPreset:ae,displayLocale:R,timeSelectorType:j,type:I,label:P,value:ne,onChange:ue=>je(ue),min:K||ce||x,max:v,placeholder:q||A("controls.endDate","End date"),disabled:O,readOnly:S,size:y,clearable:D,labelPlacement:d,labelWidth:z})})]}),X&&ye&&re&&U&&Qe.createPortal(e.jsxs("div",{ref:he,className:`nice-datetime-popup${de?` ${de}`:""}`,style:{position:"fixed",left:re.left,top:re.top,zIndex:1e3},role:"dialog","aria-label":A("controls.openPicker","Open picker"),children:[e.jsx("div",{className:"nice-datetime-popup__body",children:e.jsx("div",{className:"nice-datetime-popup__col nice-datetime-popup__col--date",children:e.jsx(rt.NiceCalendar,{selectionMode:"range",rangeStart:ze(ce),rangeEnd:ze(ne),onRangeChange:Ke,min:ze(le),max:ze(v),size:y})})}),D&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Ge,disabled:!ce&&!ne,children:A("controls.clear","Clear")})})]}),U),C&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),b==="right"&&Z&&e.jsx("div",{className:"nice-field__error",role:"alert",children:Z}),b==="right"&&!Z&&B&&e.jsx("div",{className:"nice-field__helper",children:B})]}),b!=="right"&&Z&&e.jsx("div",{className:"nice-field__error",children:Z}),b!=="right"&&!Z&&B&&e.jsx("div",{className:"nice-field__hint",children:B})]})};function ni(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"analogous-complementary":return[0,-i,i,180];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 Dt(t,i={}){const a=i.size??16,o="currentColor",r="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const G=Math.max(3,Math.min(7,i.count??5)),P=a*.1,_=a-P*2,J=Math.max(1.2,a/14),ie=a/2,ee=Array.from({length:G},(ae,R)=>{const j=P+_*R/(G-1),I=.25+.75*R/(G-1);return e.jsx("circle",{cx:j,cy:ie,r:J,fill:r,opacity:I},R)});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}),ee]})}const x=i.angles??ni(t),v=a/2,D=a/2,N=a/2-2,q=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:v,cy:D,r:N,fill:"none",stroke:o,strokeOpacity:.25}),x.map((G,P)=>{const _=(G-90)*Math.PI/180,J=v+N*Math.cos(_),ie=D+N*Math.sin(_);return e.jsx("circle",{cx:J,cy:ie,r:q,fill:r},P)})]})}function zt(t,i,a){return Math.max(i,Math.min(a,t))}function cn({h:t,s:i,v:a}){t=(t%360+360)%360;const o=a*i,r=o*(1-Math.abs(t/60%2-1)),g=a-o;let x=0,v=0,D=0;return t<60?(x=o,v=r):t<120?(x=r,v=o):t<180?(v=o,D=r):t<240?(v=r,D=o):t<300?(x=r,D=o):(x=o,D=r),{r:Math.round((x+g)*255),g:Math.round((v+g)*255),b:Math.round((D+g)*255)}}function St({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),g=o-r;let x=0;return g!==0&&(o===t?x=(i-a)/g%6:o===i?x=(a-t)/g+2:x=(t-i)/g+4,x=(x*60+360)%360),{h:x,s:o===0?0:g/o,v:o}}function ln({r:t,g:i,b:a}){t/=255,i/=255,a/=255;const o=Math.max(t,i,a),r=Math.min(t,i,a),g=(o+r)/2;if(o===r)return{h:0,s:0,l:g};const x=o-r,v=g>.5?x/(2-o-r):x/(o+r);let D=0;return o===t?D=((i-a)/x+(i<a?6:0))/6:o===i?D=((a-t)/x+2)/6:D=((t-i)/x+4)/6,{h:D*360,s:v,l:g}}function st(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 dn({r:t,g:i,b:a}){return"#"+[t,i,a].map(o=>o.toString(16).padStart(2,"0")).join("")}function De(t){return dn(cn(t))}function He(t){return St(st(t))}function mn(t,i){const a=[];for(let o=0;o<i;o++){const r=i<=1?.5:o/(i-1),g=zt(t.s*(.3+r*.7),0,1),x=zt(t.v*(1.2-r*.7),0,1);a.push(De({h:t.h,s:g,v:x}))}return a}function gt(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"analogous-complementary":return[0,-a,a,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function ot(t,i,a){return gt(i,a).map(o=>((t+o)%360+360)%360)}function Lt(t,i,a=.12){const o=Math.max(2,i),r=(o-1)/2,g=[];for(let x=0;x<o;x++){const v=(x-r)*a,D=Math.max(.05,Math.min(.98,t.v+v)),N=Math.max(.05,Math.min(1,t.s-Math.abs(v)*.25));g.push(De({h:t.h,s:N,v:D}))}return g}function Pt({r:t,g:i,b:a}){const[o,r,g]=[t,i,a].map(x=>{const v=x/255;return v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4)});return .2126*o+.7152*r+.0722*g}function mt(t,i){const a=Pt(st(t)),o=Pt(st(i)),r=Math.max(a,o),g=Math.min(a,o);return(r+.05)/(g+.05)}function ut(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const un={"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 pt(t,i){const a=un[i];return t.map(o=>{const r=(a.sRange[0]+a.sRange[1])/2,g=(a.vRange[0]+a.vRange[1])/2;return De({h:o,s:r,v:g})})}function ii(){return Math.floor(Math.random()*360)}function pn(t,i,a){const o=ii(),r=ot(o,t,a),g=[];for(let x=0;x<i;x++){const v=r[x%r.length],D=.55+Math.random()*.4,N=.5+Math.random()*.45;g.push(De({h:v+(Math.random()-.5)*8,s:D,v:N}))}return g}const ai=({hues:t,colors:i,baseHue:a,onBaseHueChange:o,mode:r,distance:g,disabled:x})=>{const P=n.useRef(null),_=n.useCallback((j,I)=>{const p=P.current;if(!p)return;const w=p.getBoundingClientRect(),X=(j-w.left)/w.width*240-120,h=(I-w.top)/w.height*240-120,f=(Math.atan2(h,X)*180/Math.PI+360)%360;o(Math.round(f))},[120,120,240,o]),J=n.useCallback(j=>{if(x)return;j.preventDefault(),_(j.clientX,j.clientY);const I=w=>_(w.clientX,w.clientY),p=()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",p)};document.addEventListener("pointermove",I),document.addEventListener("pointerup",p)},[x,_]),ie=[];for(let j=0;j<360;j+=2){const I=(j-1)*Math.PI/180,p=(j+1)*Math.PI/180,w=De({h:j,s:1,v:1});ie.push(e.jsx("path",{d:`M${120+55*Math.cos(I)},${120+55*Math.sin(I)} L${120+110*Math.cos(I)},${120+110*Math.sin(I)} A110,110 0 0,1 ${120+110*Math.cos(p)},${120+110*Math.sin(p)} L${120+55*Math.cos(p)},${120+55*Math.sin(p)} A55,55 0 0,0 ${120+55*Math.cos(I)},${120+55*Math.sin(I)} Z`,fill:w},j))}const ee=`wheel-center-${r}`,ae=t.map((j,I)=>{const w=j*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(w),cy:120+82.5*Math.sin(w),r:I===0?8:6,fill:i?.[I]??De({h:j,s:.85,v:.9}),stroke:I===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:I===0?3:2},I)});let R=null;if(r==="analogous"||r==="split-complementary"||r==="analogous-complementary"){const p=gt(r,g).slice(1).map((w,X)=>{const h=(a+w)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(h),y2:120+82.5*Math.sin(h),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${X}`)});R=e.jsx(e.Fragment,{children:p})}return e.jsxs("svg",{ref:P,className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onPointerDown:J,style:{cursor:x?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:ee,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),ie,e.jsx("circle",{cx:120,cy:120,r:53,fill:De({h:a,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${ee})`,opacity:.4}),R,ae]})},oi=({colors:t})=>{if(t.length<2)return null;const i=[];for(let a=0;a<t.length;a++){const o=mt(t[a],"var(--nice-bg-primary, #ffffff)"),r=mt(t[a],"var(--nice-text-primary, #000000)");i.push({a:t[a],b:"var(--nice-bg-primary, #ffffff)",ratio:o,level:ut(o)}),i.push({a:t[a],b:"var(--nice-text-primary, #000000)",ratio:r,level:ut(r)});for(let g=a+1;g<t.length;g++){const x=mt(t[a],t[g]);i.push({a:t[a],b:t[g],ratio:x,level:ut(x)})}}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))})]})},si=({hex:t})=>{const i=st(t),a=ln(i),o=St(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),"%"]})]})},ri={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous","analogous-complementary":"Analogous + Complementary",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},ci={"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"},li=["monochromatic","shade-chain","complementary","split-complementary","analogous","analogous-complementary","triadic","tetradic","square","custom"],hn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],gn="nice-palette-custom-schemes";function di(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(gn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function mi(t){if(!(typeof window>"u"))try{window.localStorage.setItem(gn,JSON.stringify(t))}catch{}}const fn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:g,minColors:x=1,maxColors:v=8,harmonyMode:D,onHarmonyModeChange:N,distance:q,onDistanceChange:G,preset:P,onPresetChange:_,showWheel:J=!0,showContrast:ie=!0,showInfo:ee=!0,showPresets:ae=!0,presets:R=[],showVariations:j=!0,showRandom:I=!0,variationCount:p=5,label:w,labelPlacement:X="top",disabled:h,readOnly:f,loading:B,error:te,colorCount:M,shadeStep:y,onShadeStepChange:s,customSchemes:E,onCustomSchemesChange:L,persistCustomSchemes:l=!0},c)=>{const d=u.useNiceAccessMode(o,t),b=d==="hidden";d==="disabled"&&(h=!0);const z=f||d==="readOnly",$=u.useControlId(t),{t:C}=u.useNiceTranslation(),[S,T]=n.useState("analogous-complementary"),[k,A]=n.useState(30),[O,ce]=n.useState(""),[pe,ne]=n.useState(0),[je,ve]=n.useState(.12),[_e,he]=n.useState(null),[ye,xe]=n.useState(()=>E??(l?di():[])),[re,Q]=n.useState(null),[de,F]=n.useState(!1),[H,U]=n.useState(null),[ge,le]=n.useState(""),Z=n.useContext(u.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),Y=n.useRef(null),oe=n.useRef(null),me=D??S,be=q??k,we=P??O,Me=y??je,Te=E??ye;n.useEffect(()=>{!E&&l&&mi(ye)},[ye,E,l]);const Oe=n.useCallback(W=>{xe(W),L?.(W)},[L]),qe=n.useCallback(W=>{T(W),N?.(W)},[N]),Fe=n.useCallback(W=>{A(W),G?.(W)},[G]),Ke=n.useCallback(W=>{ce(W),W&&_?.(W)},[_]),Ge=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ne=r&&r.length>0?r:Ge,ze=Ne[0],ue=n.useMemo(()=>He(ze),[ze]),Ie=n.useMemo(()=>ot(ue.h,me,be),[ue.h,me,be]),Ae=n.useCallback((W,fe,ke,Ee,Pe)=>{const tt=M??Pe??_e??Ne.length,We=tt!==void 0?Math.max(x,Math.min(v,tt)):void 0;if(fe==="shade-chain"){const Le=We??Math.max(x,5),Ye=Lt({h:W,s:ue.s||.7,v:ue.v||.6},Le,Me);g?.(Ye);return}let Je;const nt=fe==="custom"&&re?Te.find(Le=>Le.id===re):null;nt&&nt.angles.length>0?Je=nt.angles.map(Le=>((W+Le)%360+360)%360):Je=ot(W,fe,ke);let Re;if(Ee&&un[Ee]?Re=pt(Je,Ee):Re=Je.map(Le=>De({h:Le,s:ue.s||.7,v:ue.v||.85})),nt?.lightnessOffsets?.length&&(Re=Re.map((Le,Ye)=>{const Mt=nt.lightnessOffsets?.[Ye];if(Mt==null)return Le;const xt=He(Le);return De({h:xt.h,s:xt.s,v:Math.max(.05,Math.min(.98,xt.v+Mt))})})),We!==void 0){for(;Re.length<We;){const Le=Re[Re.length-1]||"#888888",Ye=He(Le);Re.push(De({h:(Ye.h+18)%360,s:Ye.s,v:Ye.v}))}Re=Re.slice(0,We)}else{for(;Re.length<x;)Re.push(Re[Re.length-1]||"var(--nice-text-secondary, #888888)");Re.length>v&&(Re=Re.slice(0,v))}g?.(Re)},[ue.s,ue.v,x,v,g,M,_e,Ne.length,Me,re,Te]),m=n.useCallback(W=>{if(!h){if(me==="custom"){const fe=De({h:W,s:ue.s||.7,v:ue.v||.85}),ke=[...Ne];ke[pe]=fe,g?.(ke);return}Ae(W,me,be,we)}},[h,me,be,we,Ae,ue.s,ue.v,Ne,pe,g]),V=n.useCallback(W=>{if(h||(qe(W),W==="custom"))return;const fe=gt(W).length,ke=fe<=1;if(M==null&&!ke){const Ee=Math.max(x,Math.min(v,fe));he(Ee),Ae(ue.h,W,be,we,Ee)}else Ae(ue.h,W,be,we)},[h,ue.h,be,we,qe,Ae,M,x,v]),se=n.useCallback(W=>{h||(Fe(W),Ae(ue.h,me,W,we))},[h,ue.h,me,we,Fe,Ae]),Ce=n.useCallback(W=>{if(h)return;Ke(W);const fe=ot(ue.h,me,be),ke=pt(fe,W);g?.(ke.slice(0,v))},[h,ue.h,me,be,v,Ke,g]),$e=n.useCallback((W,fe)=>{if(h)return;const ke=[...Ne];ke[W]=fe,g?.(ke)},[h,Ne,g]),Ue=n.useCallback(()=>{if(h||Ne.length>=v)return;const W=He(Ne[Ne.length-1]),fe=De({h:(W.h+30)%360,s:W.s,v:W.v});g?.([...Ne,fe])},[h,Ne,v,g]),Ve=n.useCallback(W=>{if(h||Ne.length<=x)return;const fe=Ne.filter((ke,Ee)=>Ee!==W);g?.(fe),pe>=fe.length&&ne(Math.max(0,fe.length-1))},[h,Ne,x,g,pe]),Pn=n.useCallback(()=>{if(h)return;const W=Math.max(x,Math.min(v,gt(me).length)),fe=pn(me,W,be);g?.(fe)},[h,x,v,me,be,g]),Et=n.useMemo(()=>{if(!j)return[];const W=Ne[pe]||Ne[0];return mn(He(W),p)},[j,Ne,pe,p]),ft=Ne[pe]||Ne[0],yt=n.useMemo(()=>{const W=He(ft);return De({h:(W.h+180)%360,s:W.s,v:W.v})},[ft]);if(n.useLayoutEffect(()=>{if(!de||!Y.current)return;le(Be.scopeThemeClass(Y.current));const W=()=>{const fe=Y.current?.getBoundingClientRect();if(!fe)return;const ke=600;let Ee=fe.left;Ee+ke>window.innerWidth-8&&(Ee=Math.max(8,window.innerWidth-ke-8));let Pe=fe.bottom+6;Pe>window.innerHeight*.5&&(Pe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),U({left:Ee,top:Pe})};return W(),window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[de]),n.useEffect(()=>{if(!de)return;const W=ke=>{const Ee=ke.target;Y.current?.contains(Ee)||oe.current?.contains(Ee)||(Ee instanceof Element?Ee:Ee?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||F(!1)},fe=ke=>{ke.key==="Escape"&&F(!1)};return document.addEventListener("mousedown",W),document.addEventListener("keydown",fe),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",fe)}},[de]),b)return null;const It=R.length>0?R:hn,Bn=e.jsxs("div",{className:"nice-palette__tab",children:[e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(Be.NiceSelect,{label:C("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:h,value:me==="custom"&&re?`custom:${re}`:me,onChange:W=>{const fe=Array.isArray(W)?W[0]:W;if(typeof fe=="string")if(fe.startsWith("custom:")){const ke=fe.slice(7);Q(ke),V("custom")}else Q(null),V(fe)},options:[...li.map(W=>({value:W,label:ri[W]})),...Te.map(W=>({value:`custom:${W.id}`,label:W.name}))],renderOption:(W,fe)=>{const ke=String(W.value),Ee=ke.startsWith("custom:"),Pe=Ee?Te.find(Je=>Je.id===ke.slice(7)):null,tt=Pe?Pe.angles:void 0,We=Ee?"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:Dt(We,{angles:tt,size:16,count:M})}),e.jsx("span",{style:{fontWeight:fe?600:400},children:W.label})]})}}),me==="shade-chain"&&e.jsx(Ze.NiceNumberInput,{label:C("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Me,onChange:W=>{const fe=typeof W=="number"?W:Number(W);Number.isNaN(fe)||(ve(fe),s?.(fe),Ae(ue.h,me,be,we))},showStepper:!0,disabled:h}),e.jsx(Ze.NiceNumberInput,{label:C("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,x),max:Math.min(12,v),step:1,precision:0,value:M??_e??Ne.length,onChange:W=>{const fe=typeof W=="number"?W:Number(W);if(!Number.isFinite(fe))return;const ke=Math.max(Math.max(2,x),Math.min(Math.min(12,v),Math.round(fe)));he(ke),me==="shade-chain"?g?.(Lt({h:ue.h,s:ue.s||.7,v:ue.v||.6},ke,Me)):setTimeout(()=>Ae(ue.h,me,be,we),0)},showStepper:!0,disabled:h})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ne.map((W,fe)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${pe===fe?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ne(fe),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:W}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:W.toUpperCase(),maxLength:7,disabled:h,onClick:ke=>ke.stopPropagation(),onChange:ke=>$e(fe,ke.target.value)}),Ne.length>x&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:ke=>{ke.stopPropagation(),Ve(fe)},disabled:h,"aria-label":"Remove color",children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},fe)),Ne.length<v&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:Ue,disabled:h,title:"Add color",children:[e.jsx(u.NiceIcon,{name:"plus",size:14}),e.jsx("span",{children:"Add"})]})]}),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:yt},title:yt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:yt.toUpperCase()})]}),I&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Pn,disabled:h,title:"Random palette","aria-label":"Random palette",children:[e.jsx(u.NiceIcon,{name:"shuffle",size:14})," Random Palette"]})]})})]}),Hn=e.jsx("div",{className:"nice-palette__tab",children:Et.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:Et.map((W,fe)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:W},title:W.toUpperCase(),onClick:()=>{h||$e(pe,W)},role:"button",tabIndex:0},fe))})]}):e.jsx("div",{className:"nice-palette__empty",children:"No variations available."})}),On=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:It.map(W=>{const fe=pt(Ie,W);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${we===W?"nice-palette__preset-card--active":""}`,onClick:()=>Ce(W),disabled:h,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:fe.map((ke,Ee)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:ke}},Ee))}),e.jsx("span",{className:"nice-palette__preset-label",children:ci[W]})]},W)})})}),Fn=e.jsxs("div",{className:"nice-palette__tab",children:[ee&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(si,{hex:ft})]}),ie&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Contrast Analysis (WCAG 2.1)"}),e.jsx(oi,{colors:Ne})]})]}),Kn=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Te.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted)"},children:C("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Te.map(W=>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:Dt("custom",{angles:W.angles,size:16})}),e.jsx("span",{style:{flex:1},children:W.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{Q(W.id),V("custom")},disabled:h,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>Oe(Te.filter(fe=>fe.id!==W.id)),disabled:h,"aria-label":`Delete ${W.name}`,children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},W.id)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:h,onClick:()=>{const W=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${Te.length+1}`):null;if(!W)return;const fe=He(Ne[0]).h,ke=Ne.map(Pe=>(He(Pe).h-fe+540)%360-180),Ee={id:`cs-${Date.now()}`,name:W,angles:ke};Oe([...Te,Ee])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:h||Te.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Te,null,2))},children:C("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:h,onClick:()=>{if(typeof window>"u")return;const W=window.prompt("Paste schemes JSON");if(W)try{const fe=JSON.parse(W);Array.isArray(fe)&&Oe(fe)}catch{}},children:C("colorPalette.importJson","Import JSON")})]})]})}),et=[{id:"colors",label:"Colors",content:Bn}];ae&&It.length>0&&et.push({id:"presets",label:"Presets",content:On}),j&&et.push({id:"variations",label:"Variations",content:Hn}),(ee||ie)&&et.push({id:"info",label:"Info",content:Fn}),et.push({id:"schemes",label:"Schemes",content:Kn});const Un=e.jsxs("div",{className:"nice-palette__popup-header",children:[J&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(ai,{hues:Ie,colors:Ne,baseHue:ue.h,onBaseHueChange:m,mode:me,distance:be,disabled:h}),(me==="analogous"||me==="split-complementary"||me==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",be,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:be,onChange:W=>se(Number(W.target.value)),disabled:h,className:"nice-palette__distance-slider"})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>F(!1),"aria-label":C("controls.confirm","Confirm"),title:C("controls.confirm","Confirm"),children:e.jsx(u.NiceIcon,{name:"check",size:18})})]}),Yn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[Un,e.jsx(Zt.NiceTabs,{tabs:et,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:c,id:$,className:`nice-field nice-palette-field ${h?"nice-palette--disabled":""} ${X==="left"?"nice-field--label-left":""} ${B?"nice-field--loading":""} ${te?"nice-field--error":""} ${i||""}`,style:a,children:[w&&e.jsx("label",{htmlFor:$,className:"nice-field__label",children:w}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:Y,className:"nice-palette__field-swatches",role:"button",tabIndex:h||z?-1:0,"aria-haspopup":"dialog","aria-expanded":de,"aria-readonly":z||void 0,"aria-label":C("colorPalette.openStudio","Open palette studio"),onClick:()=>{!h&&!z&&F(W=>!W)},onKeyDown:W=>{!h&&!z&&(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),F(fe=>!fe))},children:Ne.map((W,fe)=>e.jsx("span",{className:"nice-palette__field-swatch",style:{background:W},title:W.toUpperCase(),onClick:ke=>{ke.stopPropagation(),!h&&!z&&(ne(fe),F(!0))}},fe))}),B&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),de&&H&&Z&&Qe.createPortal(e.jsx("div",{ref:oe,className:`nice-palette__popup${ge?` ${ge}`:""}`,"data-theme":ge==="nice-dark"?"dark":ge==="nice-light"?"light":void 0,role:"dialog","aria-label":C("colorPalette.studio","Palette studio"),style:{position:"fixed",left:H.left,top:H.top,zIndex:1e3},children:Yn}),Z)]}),typeof te=="string"&&te&&e.jsx("div",{className:"nice-field__error",role:"alert",children:te})]})});fn.displayName="NiceColorPalette";function wt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Nt(t){const i=t.stops.slice().sort((o,r)=>o.position-r.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",r=t.size||"farthest-corner",g=t.positionX??50,x=t.positionY??50;return`${a}radial-gradient(${o} ${r} at ${g}% ${x}%, ${i})`}case"conic":{const o=t.angle??0,r=t.positionX??50,g=t.positionY??50;return`${a}conic-gradient(from ${o}deg at ${r}% ${g}%, ${i})`}}}function yn(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 r=o.split(",").map(N=>N.trim());let g=90,x=0;const v=r[0].match(/^(\d+)deg$/);v&&(g=parseInt(v[1]),x=1);const D=bt(r.slice(x));return{type:"linear",angle:g,repeating:a,stops:D}}if(i.includes("radial-gradient")){const o=i.match(/radial-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(x=>x.trim()),g=bt(r.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"radial",angle:0,repeating:a,stops:g.length>=2?g:wt().stops}}if(i.includes("conic-gradient")){const o=i.match(/conic-gradient\((.+)\)/)?.[1];if(!o)return null;const r=o.split(",").map(x=>x.trim()),g=bt(r.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"conic",angle:0,repeating:a,stops:g.length>=2?g:wt().stops}}return null}function bt(t){return t.map((i,a,o)=>{const r=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(r){const g=r[2]?parseFloat(r[2]):a/Math.max(1,o.length-1)*100;return{color:r[1],position:g}}return{color:i,position:a/Math.max(1,o.length-1)*100}})}function ui(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function pi(t=2){const i=["linear","radial","conic"],a=i[Math.floor(Math.random()*i.length)],o=[];for(let r=0;r<t;r++)o.push({color:ui(),position:Math.round(r/(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 xn=[{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}}],jn=n.forwardRef(({id:t,className:i,style:a,accessMode:o,value:r,onChange:g,showCssOutput:x=!0,showPresets:v=!0,showEditor:D=!0,showRandom:N=!0,maxStops:q=10,label:G,labelPlacement:P="top",disabled:_,readOnly:J,loading:ie,error:ee,errorPlacement:ae="bottom",width:R},j)=>{const I=u.useNiceAccessMode(o,t),p=I==="hidden";I==="disabled"&&(_=!0);const w=J||I==="readOnly",X=u.useControlId(t),{t:h}=u.useNiceTranslation(),f=r??wt(),B=n.useMemo(()=>Nt(f),[f]),[te,M]=n.useState(0),[y,s]=n.useState(""),E=n.useRef(null),[L,l]=n.useState(!1),[c,d]=n.useState(null),[b,z]=n.useState(""),C=n.useContext(u.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),S=n.useRef(null),T=n.useRef(null),k=typeof R=="number"?R:340;n.useLayoutEffect(()=>{if(!L||!S.current)return;z(Be.scopeThemeClass(S.current));const K=()=>{const Z=S.current?.getBoundingClientRect();if(!Z)return;let Y=Z.left;Y+k>window.innerWidth-8&&(Y=Math.max(8,window.innerWidth-k-8));let oe=Z.bottom+6;oe>window.innerHeight*.5&&(oe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),d({left:Y,top:oe})};return K(),window.addEventListener("scroll",K,!0),window.addEventListener("resize",K),()=>{window.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K)}},[L,k]),n.useEffect(()=>{if(!L)return;const K=Y=>{const oe=Y.target;S.current?.contains(oe)||T.current?.contains(oe)||(oe instanceof Element?oe:oe?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||l(!1)},Z=Y=>{Y.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",K),document.addEventListener("keydown",Z),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("keydown",Z)}},[L]);const A=n.useCallback(K=>{g?.(K)},[g]),O=n.useCallback(K=>{_||A({...f,type:K})},[_,f,A]),ce=n.useCallback(K=>{_||A({...f,angle:K})},[_,f,A]),pe=n.useCallback(K=>{_||A({...f,repeating:K})},[_,f,A]),ne=n.useCallback(K=>{_||A({...f,shape:K})},[_,f,A]),je=n.useCallback((K,Z)=>{if(_)return;const Y=f.stops.map((oe,me)=>me===K?{...oe,...Z}:oe);A({...f,stops:Y})},[_,f,A]),ve=n.useRef(!1),_e=n.useCallback((K,Z)=>{if(_||!E.current)return;K.stopPropagation(),K.preventDefault(),M(Z),ve.current=!1;const Y=me=>{if(!E.current)return;ve.current=!0;const be=E.current.getBoundingClientRect(),we=Math.round(Math.max(0,Math.min(100,(me.clientX-be.left)/be.width*100)));je(Z,{position:we})},oe=()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",oe),document.removeEventListener("pointercancel",oe)};document.addEventListener("pointermove",Y),document.addEventListener("pointerup",oe),document.addEventListener("pointercancel",oe)},[_,je]),he=n.useCallback(()=>{if(_||f.stops.length>=q)return;const K=f.stops.slice().sort((be,we)=>be.position-we.position);let Z=0,Y=K[0];for(let be=0;be<K.length-1;be++){const we=K[be+1].position-K[be].position;we>Z&&(Z=we,Y=K[be])}const oe=Math.round(Y.position+Z/2),me="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");A({...f,stops:[...f.stops,{color:me,position:oe}]})},[_,f,q,A]),ye=n.useCallback(K=>{if(_||f.stops.length<=2)return;const Z=f.stops.filter((Y,oe)=>oe!==K);A({...f,stops:Z}),te>=Z.length&&M(Z.length-1)},[_,f,te,A]),xe=n.useCallback(()=>{if(_)return;const K=2+Math.floor(Math.random()*3);A(pi(K))},[_,A]),re=n.useCallback(()=>{if(_||!y.trim())return;const K=yn(y);K&&A(K)},[_,y,A]),Q=n.useCallback(K=>{if(_||!E.current||f.stops.length>=q)return;const Z=K.target;if(ve.current||Z.closest(".nice-gradient__stop-marker")){ve.current=!1;return}const Y=E.current.getBoundingClientRect(),oe=Math.round((K.clientX-Y.left)/Y.width*100),me="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),be=[...f.stops,{color:me,position:oe}];A({...f,stops:be}),M(be.length-1)},[_,f,q,A]),de=n.useMemo(()=>f.stops.slice().sort((K,Z)=>K.position-Z.position),[f.stops]),F=n.useMemo(()=>`linear-gradient(90deg, ${de.map(K=>`${K.color} ${K.position}%`).join(", ")})`,[de]);if(p)return null;const H=e.jsxs("div",{className:"nice-gradient__tab",children:[D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(K=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${f.type===K?"nice-gradient__type-btn--active":""}`,onClick:()=>O(K),disabled:_,children:K.charAt(0).toUpperCase()+K.slice(1)},K)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:f.repeating??!1,onChange:K=>pe(K.target.checked),disabled:_}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[f.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",f.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:f.angle,onChange:K=>ce(Number(K.target.value)),disabled:_,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(K=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${f.angle===K?"nice-gradient__angle-btn--active":""}`,onClick:()=>ce(K),disabled:_,title:`${K}°`,children:e.jsx("span",{style:{transform:`rotate(${K}deg)`,display:"inline-flex"},children:e.jsx(u.NiceIcon,{name:"arrow-right",size:14})})},K))})]}),f.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(K=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(f.shape||"ellipse")===K?"nice-gradient__shape-btn--active":""}`,onClick:()=>ne(K),disabled:_,children:K},K))})]}),(f.type==="radial"||f.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",f.positionX??50,"%, ",f.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:f.positionX??50,onChange:K=>A({...f,positionX:Number(K.target.value)}),disabled:_,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:f.positionY??50,onChange:K=>A({...f,positionY:Number(K.target.value)}),disabled:_,className:"nice-gradient__slider"})]})]}),f.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",f.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:f.angle,onChange:K=>ce(Number(K.target.value)),disabled:_,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:E,className:"nice-gradient__bar",style:{background:F},onClick:Q,children:f.stops.map((K,Z)=>e.jsx("div",{className:`nice-gradient__stop-marker ${te===Z?"nice-gradient__stop-marker--active":""}`,style:{left:`${K.position}%`},onPointerDown:Y=>_e(Y,Z),onClick:Y=>{Y.stopPropagation(),M(Z),ve.current=!1},title:`${K.color} @ ${K.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:K.color}})},Z))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:he,disabled:_||f.stops.length>=q,title:"Add stop","aria-label":"Add stop",children:e.jsx(u.NiceIcon,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:de.map((K,Z)=>{const Y=f.stops.indexOf(K);return e.jsxs("div",{className:`nice-gradient__stop-row ${te===Y?"nice-gradient__stop-row--active":""}`,onClick:()=>M(Y),children:[e.jsx("input",{type:"color",value:K.color,onChange:oe=>je(Y,{color:oe.target.value}),disabled:_,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:K.color.toUpperCase(),maxLength:7,onChange:oe=>je(Y,{color:oe.target.value}),disabled:_,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:K.position,onChange:oe=>je(Y,{position:Number(oe.target.value)}),disabled:_,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),f.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>ye(Y),disabled:_,"aria-label":"Remove stop",children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},Y)})})})]}),N&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:xe,disabled:_,title:"Random gradient","aria-label":"Random gradient",children:[e.jsx(u.NiceIcon,{name:"shuffle",size:14})," Random Gradient"]})]}),U=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:xn.map((K,Z)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{_||A(K.value)},disabled:_,title:K.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Nt(K.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:K.name})]},Z))})}),ge=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${B};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${B};`),title:"Copy CSS","aria-label":"Copy CSS",children:e.jsx(u.NiceIcon,{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:y,onChange:K=>s(K.target.value),disabled:_}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:re,disabled:_,children:"Import"})]})]}),le=[{id:"editor",label:"Editor",content:H}];return v&&le.push({id:"presets",label:"Presets",content:U}),x&&le.push({id:"css",label:"CSS",content:ge}),e.jsxs("div",{ref:j,id:X,className:`nice-field nice-gradient-field ${_?"nice-gradient--disabled":""} ${P==="left"?"nice-field--label-left":""} ${ie?"nice-field--loading":""} ${ee?"nice-field--error":""} ${ae==="right"?"nice-field--error-right":""} ${i||""}`,style:a,children:[G&&e.jsx("label",{htmlFor:X,className:"nice-field__label",children:G}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:S,type:"button",className:"nice-gradient__swatch",style:{background:B},"aria-haspopup":"dialog","aria-expanded":L,"aria-readonly":w||void 0,"aria-label":"Open gradient editor",disabled:_,onClick:()=>{!_&&!w&&l(K=>!K)}}),ie&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ae==="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee}),L&&c&&C&&Qe.createPortal(e.jsx("div",{ref:T,className:`nice-gradient__popup${b?` ${b}`:""}`,"data-theme":b==="nice-dark"?"dark":b==="nice-light"?"light":void 0,role:"dialog","aria-label":"Gradient editor",style:{position:"fixed",left:c.left,top:c.top,width:R!=null?typeof R=="number"?`${R}px`:R:340,zIndex:1e3},children:e.jsxs("div",{className:"nice-gradient nice-gradient--studio",children:[e.jsxs("div",{className:"nice-gradient__popup-header",children:[e.jsx("div",{className:"nice-gradient__preview",style:{background:B}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>l(!1),"aria-label":h("controls.confirm","Confirm"),title:h("controls.confirm","Confirm"),children:e.jsx(u.NiceIcon,{name:"check",size:18})})]}),e.jsx(Zt.NiceTabs,{tabs:le,variant:"enclosed",size:"sm"})]})}),C)]}),ae!=="right"&&typeof ee=="string"&&ee&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ee})]})});jn.displayName="NiceGradientPicker";const hi=[{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"}],gi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],fi=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableImprove:g=!0,enableTranslate:x=!0,enableGenerate:v=!0,toolbar:D,languages:N=hi,textStyles:q=gi,onImprove:G,onTranslate:P,onGenerate:_,showAIToolbar:J=!0,value:ie,onChange:ee,...ae}=i,R=n.useRef(null),[j,I]=n.useState(!1),[p,w]=n.useState(!1),[X,h]=n.useState(!1),[f,B]=n.useState(""),[te,M]=n.useState(""),[y,s]=n.useState("professional"),[E,L]=n.useState(""),[l,c]=n.useState(N[0]?.code||"en"),[d,b]=n.useState(""),[z,$]=n.useState(""),{t:C}=Qt.useNiceTranslation(),S=u.useNiceAI(),{improveText:T,translate:k,generateHtml:A,isLoading:O}=u.useTextImprovement(),ce=o&&S.isConfigured,pe=n.useCallback(()=>{const re=window.getSelection();return re&&re.toString().trim()?re.toString():""},[]),ne=n.useCallback(re=>{const Q=window.getSelection();if(Q&&Q.rangeCount>0){const de=Q.getRangeAt(0);de.deleteContents();const F=document.createElement("div");F.innerHTML=re;const H=document.createDocumentFragment();for(;F.firstChild;)H.appendChild(F.firstChild);if(de.insertNode(H),R.current){const U=R.current.innerHTML;ee?.(U)}}},[ee]),je=n.useCallback(async(re="professional")=>{if(!ce||!g)return"";const Q=pe();if(!Q)return"";B(Q),s(re),I(!0),M("");try{const de=await T(Q,re);return M(de),G?.(Q,de,re),de}catch{return M(C("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ce,g,pe,T,G,C]),ve=n.useCallback(async re=>{if(!ce||!x)return"";const Q=pe();if(!Q)return"";B(Q),c(re),w(!0),L("");try{const de=N.find(H=>H.code===re)?.label||re,F=await k(Q,de);return L(F),P?.(Q,F,re),F}catch{return L(C("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ce,x,pe,k,N,P,C]),_e=n.useCallback(async re=>{if(!ce||!v||!re.trim())return"";b(re),$("");try{const Q=await A(re);return $(Q),_?.(re,Q),Q}catch{return $(C("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ce,v,A,_,C]),he=n.useCallback(()=>{te&&ne(te),I(!1),M("")},[te,ne]),ye=n.useCallback(()=>{E&&ne(E),w(!1),L("")},[E,ne]),xe=n.useCallback(()=>{if(z&&R.current){document.execCommand("insertHTML",!1,z);const re=R.current.innerHTML;ee?.(re)}h(!1),$(""),b("")},[z,ee]);return n.useImperativeHandle(a,()=>({getEditor:()=>R.current,focus:()=>R.current?.focus(),getValue:()=>R.current?.innerHTML||"",setValue:re=>{R.current&&(R.current.innerHTML=re,ee?.(re))},getSelection:pe,insertHtml:re=>{document.execCommand("insertHTML",!1,re),R.current&&ee?.(R.current.innerHTML)},improveSelection:je,translateSelection:ve,generateHtml:_e})),n.useCallback(re=>{R.current=re},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[J&&ce&&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"}),O&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:C("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:()=>je(),disabled:O,title:C("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(u.NiceIcon,{name:"star",size:14})," ",C("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:q.map(({style:re,label:Q})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>je(re),children:Q},re))})]}),x&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:O,title:C("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(u.NiceIcon,{name:"globe",size:14})," ",C("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:N.map(({code:re,label:Q})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ve(re),children:Q},re))})]}),v&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>h(!0),disabled:O,title:C("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(u.NiceIcon,{name:"zap",size:14})," ",C("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(Xn.NiceHtmlEditor,{value:ie,onChange:ee,toolbar:D,...ae})}),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(u.NiceIcon,{name:"star",size:16})," ",C("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:q.map(({style:re,label:Q})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${y===re?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{s(re),je(re)},children:Q},re))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":C("htmlEditorAI.close","Close"),onClick:()=>I(!1),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:O?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:C("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:C("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:f})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:C("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:te})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:he,disabled:!te||O,children:[e.jsx(u.NiceIcon,{name:"check",size:14})," ",C("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{I(!1),M("")},children:C("htmlEditorAI.cancel","Cancel")})]})]}),p&&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(u.NiceIcon,{name:"globe",size:16})," ",C("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:l,onChange:re=>{c(re.target.value),ve(re.target.value)},className:"nice-html-editor-ai__language-select",children:N.map(({code:re,label:Q})=>e.jsx("option",{value:re,children:Q},re))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":C("htmlEditorAI.close","Close"),onClick:()=>w(!1),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:O?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:C("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:C("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:f})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:N.find(re=>re.code===l)?.label||l}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:E})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ye,disabled:!E||O,children:[e.jsx(u.NiceIcon,{name:"check",size:14})," ",C("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{w(!1),L("")},children:C("htmlEditorAI.cancel","Cancel")})]})]}),X&&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(u.NiceIcon,{name:"zap",size:16})," ",C("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":C("htmlEditorAI.close","Close"),onClick:()=>{h(!1),$(""),b("")},children:e.jsx(u.NiceIcon,{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:C("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:d,onChange:re=>b(re.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>_e(d),disabled:O||!d.trim(),children:O?C("htmlEditorAI.generating","Generating..."):C("htmlEditorAI.generate","Generate")})]}),z&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:C("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:z}}),e.jsx("h5",{children:C("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:z})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:xe,disabled:!z||O,children:[e.jsx(u.NiceIcon,{name:"check",size:14})," ",C("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{h(!1),$(""),b("")},children:C("htmlEditorAI.cancel","Cancel")})]})]})]})}),yi=[{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 xi(t){let i=t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(a,o,r)=>`<pre><code class="language-${o}">${r.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(a,o,r,g)=>{const x=o.split("|").filter(D=>D.trim()).map(D=>`<th>${D.trim()}</th>`).join(""),v=g.trim().split(`
2
+ `).map(D=>`<tr>${D.split("|").filter(q=>q.trim()).map(q=>`<td>${q.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${x}</tr></thead><tbody>${v}</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"><input type="checkbox" checked disabled> $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task"><input type="checkbox" disabled> $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 ji=[{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:`---
3
+ `,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 |
4
+ | --- | --- | --- |
5
+ | c1 | c2 | c3 |
6
+ `,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],bi=["format","heading","list","block","insert"],bn=n.forwardRef(({value:t="",onChange:i,preview:a="side",placeholder:o,disabled:r,readOnly:g,size:x="md",editorSize:v="standard",toolbar:D=!0,minHeight:N=200,showWordCount:q=!1,showLineNumbers:G=!1,onExportHtml:P,onImageUpload:_,tutorial:J,className:ie,style:ee,id:ae},R)=>{const j=u.useControlId(ae),[I,p]=n.useState("edit"),[w,X]=n.useState(!1),h=n.useRef(null),f=n.useMemo(()=>xi(t),[t]),B=n.useMemo(()=>{const l=t.trim()?t.trim().split(/\s+/).length:0,c=t.length,d=t.split(`
7
+ `).length;return{words:l,chars:c,lines:d}},[t]),te=n.useCallback(l=>{const c=h.current;if(!c)return;const d=c.selectionStart,b=c.selectionEnd,z=t.slice(d,b);let $,C;l==="[](url)"?($=t.slice(0,d)+`[${z||"text"}](url)`+t.slice(b),C=d+1+(z||"text").length+2):l==="![](url)"?($=t.slice(0,d)+`![${z||"alt"}](url)`+t.slice(b),C=d+2+(z||"alt").length+2):l.endsWith(`
8
+ `)||l.endsWith(" ")?($=t.slice(0,d)+l+z+t.slice(b),C=d+l.length+z.length):($=t.slice(0,d)+l+z+l+t.slice(b),C=d+l.length+z.length+l.length),i?.($),requestAnimationFrame(()=>{c.focus(),c.setSelectionRange(C,C)})},[t,i]),M=n.useCallback(l=>{if((l.ctrlKey||l.metaKey)&&(l.key==="b"?(l.preventDefault(),te("**")):l.key==="i"?(l.preventDefault(),te("*")):l.key==="k"&&(l.preventDefault(),te("[](url)"))),l.key==="Tab"){l.preventDefault();const c=l.currentTarget,d=c.selectionStart,b=c.selectionEnd,z=" ";if(l.shiftKey){const S=t.slice(0,d).lastIndexOf(`
9
+ `)+1;if(t.slice(S,S+z.length)===z){const T=t.slice(0,S)+t.slice(S+z.length);i?.(T),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=d-z.length})}}else{const $=t.slice(0,d)+z+t.slice(b);i?.($),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=d+z.length})}}},[t,i,te]),y=n.useCallback(async l=>{if(!_)return;const c=Array.from(l.dataTransfer.files).filter(d=>d.type.startsWith("image/"));if(c.length!==0){l.preventDefault();for(const d of c){const b=await _(d),z=h.current;if(!z)continue;const $=z.selectionStart,C=`![${d.name}](${b})
10
+ `,S=t.slice(0,$)+C+t.slice($);i?.(S)}}},[t,i,_]),s=a!=="tab"||I==="edit",E=a==="side"||a==="tab"&&I==="preview"||a===!0,L=`nice-md-editor nice-md-editor--${x} nice-editor--${v} nice-md-editor--preview-${a}${w?" nice-md-editor--fullscreen":""} ${ie||""}`;return e.jsxs("div",{ref:R,id:j,className:L,style:{position:"relative",...ee},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(J,yi)})}),D&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[bi.map((l,c)=>e.jsxs(n.Fragment,{children:[c>0&&e.jsx("span",{className:"nice-md-editor__sep"}),ji.filter(d=>d.group===l).map(d=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:d.shortcut?`${d.tip} (${d.shortcut})`:d.tip,disabled:r||g,onClick:()=>te(d.md),"aria-label":d.tip,children:d.icon?e.jsx(u.NiceIcon,{name:d.icon,size:16}):d.label},d.key))]},l)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:()=>X(!w),children:e.jsx(u.NiceIcon,{name:w?"collapse":"expand",size:16})}),P&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML","aria-label":"Export HTML",onClick:()=>P(f),children:e.jsx(u.NiceIcon,{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${I==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>p("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${I==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>p("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:N},children:[s&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[G&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:B.lines},(l,c)=>e.jsx("div",{className:"nice-md-editor__line-no",children:c+1},c))}),e.jsx("textarea",{ref:h,className:"nice-md-editor__textarea",value:t,onChange:l=>i?.(l.target.value),onKeyDown:M,onDrop:y,placeholder:o,disabled:r,readOnly:g,style:{minHeight:N}})]}),E&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:u.sanitizeHtml(f)},style:{minHeight:N}})]}),q&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[B.words," words"]}),e.jsxs("span",{children:[B.chars," chars"]}),e.jsxs("span",{children:[B.lines," lines"]})]})]})});bn.displayName="NiceMarkdownEditor";const vi=[{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 _i=0;function $t(){return`blk-${++_i}-${Date.now().toString(36)}`}function Bt(t=""){return{id:$t(),type:"paragraph",content:t}}function ki(t,i=""){const a={id:$t(),type:t,content:i};return t==="heading"&&(a.level=2),t==="list"&&(a.listType="unordered"),t==="toggle"&&(a.open=!0),a}const wi=[{type:"paragraph",label:"Text",icon:"align-left",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"type",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"list",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"list-ordered",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"check-square",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"quote",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"info",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"chevron-right",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"code",keywords:"code snippet"},{type:"image",label:"Image",icon:"image",keywords:"image photo picture"},{type:"video",label:"Video",icon:"video",keywords:"video embed"},{type:"table",label:"Table",icon:"table",keywords:"table grid"},{type:"divider",label:"Divider",icon:"minus",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"page-break",keywords:"page break"}];function Ni(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=(r,g)=>{let x=g;return t.bold&&(x=`<strong>${x}</strong>`),t.italic&&(x=`<em>${x}</em>`),t.underline&&(x=`<u>${x}</u>`),t.strikethrough&&(x=`<s>${x}</s>`),`<${r}${a}>${x}</${r}>`};switch(t.type){case"heading":return o(`h${t.level??2}`,t.content);case"paragraph":return o("p",t.content||"&nbsp;");case"list":{const r=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
11
+ `).map((x,v)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[v]??!1?"checked":""} disabled />${x}</li>`:`<li>${x}</li>`).join("");return`<${r}${a}>${g}</${r}>`}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}>${t.icon?`<span>${t.icon}</span>`:""}<div>${t.content}</div></div>`;case"toggle":return`<details${a}><summary>${t.content.split(`
12
+ `)[0]}</summary>${t.content.split(`
13
+ `).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 Ci(t){let i=0,a=0;for(const o of t){const r=o.content??"";i+=r.length;const g=r.trim().split(/\s+/).filter(Boolean);a+=g.length}return{words:a,chars:i,readingTime:Math.max(1,Math.ceil(a/200))}}const vn=n.forwardRef(({blocks:t,onChange:i,readOnly:a=!1,showToolbar:o=!0,size:r="md",editorSize:g="standard",placeholder:x,onExport:v,onImageUpload:D,maxUndo:N=50,slashCommands:q=!0,showWordCount:G=!1,showToc:P=!1,showFindReplace:_=!0,tutorial:J,className:ie,style:ee,id:ae,...R},j)=>{const I=u.useControlId(ae),{t:p}=u.useNiceTranslation(),[w,X]=n.useState(()=>t??[Bt()]),h=t??w,[f,B]=n.useState(0),te=n.useRef(new Map),M=n.useRef(null),[y,s]=n.useState(!1),[E,L]=n.useState(""),[l,c]=n.useState(""),[d,b]=n.useState([]),[z,$]=n.useState(0),[C,S]=n.useState(!1),T=n.useRef([]),k=n.useRef([]),A=n.useCallback(m=>{T.current.push(m.map(V=>({...V,checked:V.checked?[...V.checked]:void 0}))),T.current.length>N&&T.current.shift(),k.current=[]},[N]),O=n.useCallback(()=>{if(T.current.length===0)return;const m=T.current.pop();k.current.push(h.map(V=>({...V}))),t||X(m),i?.(m)},[h,t,i]),ce=n.useCallback(()=>{if(k.current.length===0)return;const m=k.current.pop();T.current.push(h.map(V=>({...V}))),t||X(m),i?.(m)},[h,t,i]),[pe,ne]=n.useState(!1),[je,ve]=n.useState(""),[_e,he]=n.useState(0),ye=n.useMemo(()=>{if(!pe||!q)return[];const m=je.toLowerCase();return wi.filter(V=>V.label.toLowerCase().includes(m)||V.keywords.includes(m))},[pe,je,q]),[xe,re]=n.useState(null),[Q,de]=n.useState(null),F=n.useCallback(m=>{A(h);const V=m(h);t||X(V),i?.(V)},[h,t,i,A]),H=n.useCallback((m,V)=>{F(se=>se.map((Ce,$e)=>$e===m?{...Ce,...V}:Ce))},[F]),U=n.useCallback((m,V)=>{const se=V??Bt();F(Ce=>{const $e=[...Ce];return $e.splice(m+1,0,se),$e}),B(m+1)},[F]),ge=n.useCallback(m=>{const V={...h[m],id:$t()};U(m,V)},[h,U]),le=n.useCallback(m=>{h.length<=1||(F(V=>V.filter((se,Ce)=>Ce!==m)),B(Math.max(0,m-1)))},[h.length,F]),K=n.useCallback((m,V)=>{const se=m+V;se<0||se>=h.length||(F(Ce=>{const $e=[...Ce];return[$e[m],$e[se]]=[$e[se],$e[m]],$e}),B(se))},[h.length,F]),Z=n.useCallback((m,V)=>{const se={type:V};V==="heading"&&(se.level=2),V==="list"&&(se.listType="unordered"),V==="toggle"&&(se.open=!0),H(m,se)},[H]),Y=n.useCallback(m=>{const V=ki(m.type);m.type==="list"&&m.label.includes("Numbered")&&(V.listType="ordered"),m.type==="list"&&m.label.includes("Checklist")&&(V.listType="checklist",V.checked=[]),h[f]?.content===""||h[f]?.content==="/"?F(se=>se.map((Ce,$e)=>$e===f?{...V,id:Ce.id}:Ce)):U(f,V),ne(!1),ve("")},[h,f,F,U]),oe=n.useCallback((m,V)=>{if(a)return;const se=h[V];if(!se?.locked){if((m.ctrlKey||m.metaKey)&&m.key==="z"&&!m.shiftKey){m.preventDefault(),O();return}if((m.ctrlKey||m.metaKey)&&(m.key==="y"||m.key==="z"&&m.shiftKey)){m.preventDefault(),ce();return}if((m.ctrlKey||m.metaKey)&&m.key==="d"){m.preventDefault(),ge(V);return}if((m.ctrlKey||m.metaKey)&&m.key==="b"){m.preventDefault(),H(V,{bold:!se?.bold});return}if((m.ctrlKey||m.metaKey)&&m.key==="i"){m.preventDefault(),H(V,{italic:!se?.italic});return}if((m.ctrlKey||m.metaKey)&&m.key==="u"){m.preventDefault(),H(V,{underline:!se?.underline});return}if((m.ctrlKey||m.metaKey)&&m.key==="e"){m.preventDefault(),H(V,{strikethrough:!se?.strikethrough});return}if(m.key==="Tab"&&!m.shiftKey){m.preventDefault(),H(V,{indent:Math.min((se?.indent??0)+1,4)});return}if(m.key==="Tab"&&m.shiftKey){m.preventDefault(),H(V,{indent:Math.max((se?.indent??0)-1,0)});return}if((m.ctrlKey||m.metaKey)&&m.key==="f"&&_){m.preventDefault(),s(Ce=>!Ce);return}if(pe&&ye.length>0){if(m.key==="ArrowDown"){m.preventDefault(),he(Ce=>Math.min(Ce+1,ye.length-1));return}if(m.key==="ArrowUp"){m.preventDefault(),he(Ce=>Math.max(Ce-1,0));return}if(m.key==="Enter"){m.preventDefault(),Y(ye[_e]);return}if(m.key==="Escape"){ne(!1);return}}m.key==="Enter"&&!m.shiftKey?(m.preventDefault(),U(V)):m.key==="Backspace"&&h[V].content===""&&h.length>1?(m.preventDefault(),le(V)):m.key==="ArrowUp"&&m.altKey?(m.preventDefault(),K(V,-1)):m.key==="ArrowDown"&&m.altKey&&(m.preventDefault(),K(V,1))}},[a,h,U,le,K,O,ce,ge,H,pe,ye,_e,Y,_]),me=n.useCallback((m,V)=>{const se=m.target.textContent??"";q&&se.startsWith("/")?(ne(!0),ve(se.slice(1)),he(0)):pe&&ne(!1),A(h);const Ce=h.map(($e,Ue)=>Ue===V?{...$e,content:se}:$e);t||X(Ce),i?.(Ce)},[h,t,i,A,q,pe]),be=n.useCallback((m,V)=>{re(V),m.dataTransfer.effectAllowed="move"},[]),we=n.useCallback((m,V)=>{m.preventDefault(),m.dataTransfer.dropEffect="move",de(V)},[]),Me=n.useCallback((m,V)=>{if(m.preventDefault(),xe===null||xe===V){re(null),de(null);return}F(se=>{const Ce=[...se],[$e]=Ce.splice(xe,1);return Ce.splice(V>xe?V-1:V,0,$e),Ce}),B(V>xe?V-1:V),re(null),de(null)},[xe,F]);n.useEffect(()=>{if(!y||!E){b([]);return}const m=E.toLowerCase(),V=[];h.forEach((se,Ce)=>{const $e=(se.content??"").toLowerCase();let Ue=0;for(;Ue<$e.length;){const Ve=$e.indexOf(m,Ue);if(Ve===-1)break;V.push({blockIdx:Ce,start:Ve,end:Ve+m.length}),Ue=Ve+1}}),b(V),$(0)},[E,y,h]);const Te=n.useCallback(()=>{if(d.length===0)return;const m=(z+1)%d.length;$(m),B(d[m].blockIdx)},[d,z]),Oe=n.useCallback(()=>{if(d.length===0)return;const m=(z-1+d.length)%d.length;$(m),B(d[m].blockIdx)},[d,z]),qe=n.useCallback(()=>{if(d.length===0||!E)return;const m=d[z],V=h[m.blockIdx],se=V.content.slice(0,m.start),Ce=V.content.slice(m.end);H(m.blockIdx,{content:se+l+Ce})},[d,z,E,l,h,H]),Fe=n.useCallback(()=>{if(!E)return;const m=E;F(V=>V.map(se=>({...se,content:se.content.split(m).join(l)})))},[E,l,F]),Ke=n.useMemo(()=>P?h.map((m,V)=>m.type==="heading"?{idx:V,level:m.level??2,text:m.content}:null).filter(Boolean):[],[h,P]),Ge=n.useCallback(async m=>{const V=m.target.files?.[0];if(V){if(D){const se=await D(V);H(f,{src:se})}m.target.value=""}},[D,f,H]);n.useEffect(()=>{const m=h[f];if(m){const V=te.current.get(m.id);V&&V.focus()}},[f,h]);const Ne=n.useCallback(()=>{const m=h.map(Ni).join(`
14
+ `);v?.(m)},[h,v]),ze=n.useMemo(()=>G?Ci(h):null,[h,G]),[ue,Ie]=n.useState(null),Ae=n.useCallback((m,V)=>{a||(m.preventDefault(),Ie({x:m.clientX,y:m.clientY,idx:V}))},[a]);return n.useEffect(()=>{if(!ue)return;const m=()=>Ie(null);return window.addEventListener("click",m),()=>window.removeEventListener("click",m)},[ue]),e.jsxs("div",{ref:j,id:I,className:`nice-doc-editor nice-doc-editor--${r} nice-editor--${g} ${a?"nice-doc-editor--readonly":""} ${ie??""}`,style:{position:"relative",...ee},role:"application","aria-label":p("docEditor.label","Document Editor"),...R,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(J,vi)})}),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(Se.NiceButton,{size:"sm",variant:"ghost",onClick:O,title:p("docEditor.undo","Undo (Ctrl+Z)"),ariaLabel:p("docEditor.undo","Undo (Ctrl+Z)"),children:e.jsx(u.NiceIcon,{name:"undo",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:ce,title:p("docEditor.redo","Redo (Ctrl+Y)"),ariaLabel:p("docEditor.redo","Redo (Ctrl+Y)"),children:e.jsx(u.NiceIcon,{name:"redo",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Be.NiceSelect,{size:"sm",value:h[f]?.type??"paragraph",onChange:m=>Z(f,m),label:"",options:[{value:"paragraph",label:p("docEditor.paragraph","Paragraph")},{value:"heading",label:p("docEditor.heading","Heading")},{value:"list",label:p("docEditor.list","List")},{value:"code",label:p("docEditor.code","Code")},{value:"quote",label:p("docEditor.quote","Quote")},{value:"callout",label:p("docEditor.callout","Callout")},{value:"toggle",label:p("docEditor.toggle","Toggle")},{value:"divider",label:p("docEditor.divider","Divider")},{value:"image",label:p("docEditor.image","Image")},{value:"video",label:p("docEditor.video","Video")},{value:"pageBreak",label:p("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),h[f]?.type==="heading"&&e.jsx(Be.NiceSelect,{size:"sm",value:String(h[f]?.level??2),onChange:m=>H(f,{level:Number(m)}),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}}),h[f]?.type==="list"&&e.jsx(Be.NiceSelect,{size:"sm",value:h[f]?.listType??"unordered",onChange:m=>H(f,{listType:m}),label:"",options:[{value:"unordered",label:"Bullets"},{value:"ordered",label:"Numbers"},{value:"checklist",label:"Checklist"}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.bold?"primary":"ghost",onClick:()=>H(f,{bold:!h[f]?.bold}),title:p("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.italic?"primary":"ghost",onClick:()=>H(f,{italic:!h[f]?.italic}),title:p("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.underline?"primary":"ghost",onClick:()=>H(f,{underline:!h[f]?.underline}),title:p("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.strikethrough?"primary":"ghost",onClick:()=>H(f,{strikethrough:!h[f]?.strikethrough}),title:p("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.align==="left"?"primary":"ghost",onClick:()=>H(f,{align:"left"}),title:p("docEditor.alignLeft","Left"),ariaLabel:p("docEditor.alignLeft","Left"),children:e.jsx(u.NiceIcon,{name:"align-left",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.align==="center"?"primary":"ghost",onClick:()=>H(f,{align:"center"}),title:p("docEditor.alignCenter","Center"),ariaLabel:p("docEditor.alignCenter","Center"),children:e.jsx(u.NiceIcon,{name:"align-center",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.align==="right"?"primary":"ghost",onClick:()=>H(f,{align:"right"}),title:p("docEditor.alignRight","Right"),ariaLabel:p("docEditor.alignRight","Right"),children:e.jsx(u.NiceIcon,{name:"align-right",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>H(f,{indent:Math.min((h[f]?.indent??0)+1,4)}),title:p("docEditor.indent","Indent (Tab)"),ariaLabel:p("docEditor.indent","Indent (Tab)"),children:e.jsx(u.NiceIcon,{name:"indent",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>H(f,{indent:Math.max((h[f]?.indent??0)-1,0)}),title:p("docEditor.outdent","Outdent (Shift+Tab)"),ariaLabel:p("docEditor.outdent","Outdent (Shift+Tab)"),children:e.jsx(u.NiceIcon,{name:"outdent",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:h[f]?.color??"var(--nice-text-primary, #000000)",onChange:m=>H(f,{color:m}),title:"Text color"}),e.jsx(Se.NiceColorPicker,{size:"sm",label:"",value:h[f]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:m=>H(f,{bgColor:m}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Se.NiceButton,{size:"sm",variant:h[f]?.locked?"primary":"ghost",onClick:()=>H(f,{locked:!h[f]?.locked}),title:p("docEditor.lock","Lock/Unlock block"),ariaLabel:p("docEditor.lock","Lock/Unlock block"),children:e.jsx(u.NiceIcon,{name:h[f]?.locked?"lock":"unlock",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ge(f),title:p("docEditor.duplicate","Duplicate (Ctrl+D)"),ariaLabel:p("docEditor.duplicate","Duplicate (Ctrl+D)"),children:e.jsx(u.NiceIcon,{name:"copy",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>le(f),title:p("docEditor.delete","Delete block"),ariaLabel:p("docEditor.delete","Delete block"),children:e.jsx(u.NiceIcon,{name:"trash",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>U(f),title:p("docEditor.addBlock","Add block"),ariaLabel:p("docEditor.addBlock","Add block"),children:e.jsx(u.NiceIcon,{name:"plus",size:"sm"})}),_&&e.jsx(Se.NiceButton,{size:"sm",variant:y?"primary":"ghost",onClick:()=>s(m=>!m),title:p("docEditor.find","Find & Replace (Ctrl+F)"),ariaLabel:p("docEditor.find","Find & Replace (Ctrl+F)"),children:e.jsx(u.NiceIcon,{name:"search",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>S(m=>!m),title:p("docEditor.shortcuts","Keyboard shortcuts"),ariaLabel:p("docEditor.shortcuts","Keyboard shortcuts"),children:e.jsx(u.NiceIcon,{name:"keyboard",size:"sm"})}),v&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Ne,children:p("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:M,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Ge}),y&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)"},children:[e.jsx(Ze.NiceTextInput,{size:"sm",placeholder:p("docEditor.findPlaceholder","Find..."),value:E,onChange:L,style:{flex:1,maxWidth:200}}),e.jsx(Ze.NiceTextInput,{size:"sm",placeholder:p("docEditor.replacePlaceholder","Replace..."),value:l,onChange:c,style:{flex:1,maxWidth:200}}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Oe,title:p("docEditor.findPrev","Previous"),ariaLabel:p("docEditor.findPrev","Previous"),children:e.jsx(u.NiceIcon,{name:"chevron-up",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Te,title:p("docEditor.findNext","Next"),ariaLabel:p("docEditor.findNext","Next"),children:e.jsx(u.NiceIcon,{name:"chevron-down",size:"sm"})}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:qe,title:p("docEditor.replaceOne","Replace"),disabled:a,children:p("docEditor.replace","Replace")}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:Fe,title:p("docEditor.replaceAll","Replace all"),disabled:a,children:p("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:d.length>0?`${z+1}/${d.length}`:"0/0"}),e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>s(!1),title:p("docEditor.closeFind","Close"),ariaLabel:p("docEditor.closeFind","Close"),children:e.jsx(u.NiceIcon,{name:"close",size:"sm"})})]}),C&&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:()=>S(!1),children:e.jsxs("div",{style:{background:"var(--nice-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:m=>m.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:p("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",p("docEditor.bold","Bold")],["Ctrl+I",p("docEditor.italic","Italic")],["Ctrl+U",p("docEditor.underline","Underline")],["Ctrl+E",p("docEditor.strikethrough","Strikethrough")],["Ctrl+D",p("docEditor.duplicate","Duplicate block")],["Ctrl+Z",p("docEditor.undo","Undo")],["Ctrl+Y",p("docEditor.redo","Redo")],["Ctrl+F",p("docEditor.find","Find & Replace")],["Enter",p("docEditor.newBlock","New block")],["Backspace",p("docEditor.deleteEmpty","Delete empty block")],["Alt+↑",p("docEditor.moveUp","Move block up")],["Alt+↓",p("docEditor.moveDown","Move block down")],["Tab",p("docEditor.indent","Indent")],["Shift+Tab",p("docEditor.outdent","Outdent")],["/",p("docEditor.slashCmd","Slash commands")]].map(([m,V])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:m}),e.jsx("td",{style:{padding:"4px 8px"},children:V})]},m))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>S(!1),children:p("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[P&&Ke.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-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(--nice-text-muted, #999)"},children:p("docEditor.toc","Contents")}),Ke.map(m=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(m.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:m.idx===f?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>B(m.idx),title:m.text,children:m.text||p("docEditor.untitled","Untitled")},m.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:h.map((m,V)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${m.type} ${V===f?"nice-doc-editor__block--focused":""} ${Q===V?"nice-doc-editor__block--drop-target":""} ${m.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>B(V),onContextMenu:se=>Ae(se,V),draggable:!a&&!m.locked,onDragStart:se=>be(se,V),onDragOver:se=>we(se,V),onDrop:se=>Me(se,V),onDragEnd:()=>{re(null),de(null)},style:{opacity:xe===V?.4:1,marginLeft:(m.indent??0)*24},children:[!a&&!m.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:p("docEditor.drag","Drag to reorder"),children:e.jsx(u.NiceIcon,{name:"grip",size:"sm"})}),m.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:e.jsx(u.NiceIcon,{name:"lock",size:"sm"})}),m.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):m.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(--nice-text-muted, #999)"},children:["— ",p("docEditor.pageBreak","Page Break")," —"]}):m.type==="image"||m.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:m.src?m.type==="image"?e.jsx("img",{src:m.src,alt:m.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:m.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(Ze.NiceTextInput,{size:"sm",placeholder:p("docEditor.mediaUrl",m.type==="image"?"Image URL":"Video URL"),value:m.src??"",onChange:se=>H(V,{src:se})}),D&&e.jsx(Se.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{B(V),M.current?.click()},title:p("docEditor.upload","Upload file"),ariaLabel:p("docEditor.upload","Upload file"),children:e.jsx(u.NiceIcon,{name:"upload",size:"sm"})})]})}):m.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:m.bgColor??"#f0f7ff",borderRadius:4,color:m.color},children:[e.jsx("span",{style:{fontSize:"1.2em",display:"inline-flex"},children:m.icon??e.jsx(u.NiceIcon,{name:"info",size:"sm"})}),e.jsx("div",{ref:se=>{se&&te.current.set(m.id,se)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:se=>me(se,V),onFocus:()=>B(V),onKeyDown:se=>oe(se,V),"data-placeholder":p("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:m.content})]}):m.type==="toggle"?e.jsxs("details",{open:m.open,className:"nice-doc-editor__toggle",onToggle:se=>H(V,{open:se.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:m.content.split(`
15
+ `)[0]||p("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:se=>{se&&te.current.set(m.id,se)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:se=>me(se,V),onFocus:()=>B(V),onKeyDown:se=>oe(se,V),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:m.content.split(`
16
+ `).slice(1).join(`
17
+ `)})]}):m.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!a&&e.jsx(Ze.NiceTextInput,{size:"sm",value:m.language??"",onChange:se=>H(V,{language:se}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:se=>{se&&te.current.set(m.id,se)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,onInput:se=>me(se,V),onFocus:()=>B(V),onKeyDown:se=>oe(se,V),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:m.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:se=>{se&&te.current.set(m.id,se)},className:"nice-doc-editor__content",contentEditable:!a&&!m.locked,suppressContentEditableWarning:!0,style:{textAlign:m.align,fontWeight:m.bold?"bold":void 0,fontStyle:m.italic?"italic":void 0,textDecoration:[m.underline?"underline":"",m.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:m.color,backgroundColor:m.bgColor},onInput:se=>me(se,V),onFocus:()=>B(V),onKeyDown:se=>oe(se,V),"data-placeholder":!m.content&&x?x:void 0,role:"textbox","aria-multiline":"true",children:m.content}),pe&&V===f&&ye.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-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:ye.map((se,Ce)=>e.jsxs("li",{className:Ce===_e?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Ce===_e?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:$e=>{$e.preventDefault(),Y(se)},onMouseEnter:()=>he(Ce),children:[e.jsx("span",{style:{width:24,display:"inline-flex",justifyContent:"center"},children:e.jsx(u.NiceIcon,{name:se.icon,size:"sm"})}),e.jsx("span",{children:se.label})]},`${se.type}-${se.label}`))})]})]},m.id))})]}),ue&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:ue.x,top:ue.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-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.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ge(ue.idx),Ie(null)},children:[e.jsx(u.NiceIcon,{name:"copy",size:"sm"})," Duplicate"]}),e.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{U(ue.idx),Ie(null)},children:[e.jsx(u.NiceIcon,{name:"plus",size:"sm"})," Insert below"]}),e.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{K(ue.idx,-1),Ie(null)},children:[e.jsx(u.NiceIcon,{name:"arrow-up",size:"sm"})," Move up"]}),e.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{K(ue.idx,1),Ie(null)},children:[e.jsx(u.NiceIcon,{name:"arrow-down",size:"sm"})," Move down"]}),e.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{H(ue.idx,{locked:!h[ue.idx]?.locked}),Ie(null)},children:[e.jsx(u.NiceIcon,{name:h[ue.idx]?.locked?"unlock":"lock",size:"sm"})," ",h[ue.idx]?.locked?"Unlock":"Lock"]}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsxs("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{le(ue.idx),Ie(null)},children:[e.jsx(u.NiceIcon,{name:"trash",size:"sm"})," Delete"]})]}),G&&ze&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[ze.words," ",p("docEditor.words","words")]}),e.jsxs("span",{children:[ze.chars," ",p("docEditor.chars","characters")]}),e.jsxs("span",{children:[h.length," ",p("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ze.readingTime," ",p("docEditor.readingTime","min read")]})]})]})});vn.displayName="NiceDocumentEditor";const Si=[],_n=n.forwardRef(({label:t,helperText:i,error:a,disabled:o,readOnly:r,size:g="md",id:x,className:v,style:D,accessMode:N,pages:q=Si,selectedPageId:G,content:P="",contentFormat:_="html",editing:J=!1,onPageSelect:ie,onContentChange:ee,onSave:ae,onCreatePage:R,onDeletePage:j,onEditToggle:I,onVersionHistory:p,sidebarWidth:w=260,sidebarCollapsed:X=!1,onSidebarToggle:h,searchable:f=!0,onSearch:B},te)=>{const M=u.useNiceAccessMode(N,x),y=M==="hidden";M==="disabled"&&(o=!0),M==="readOnly"&&(r=!0);const{t:s}=u.useNiceTranslation(),E=u.useControlId(x),[L,l]=n.useState(""),[c,d]=n.useState(""),[b,z]=n.useState(!1),$=n.useMemo(()=>{const k=A=>{for(const O of A){if(O.id===G)return O;if(O.children){const ce=k(O.children);if(ce)return ce}}};return k(q)},[q,G]),C=n.useCallback(k=>{l(k),B?.(k)},[B]),S=n.useCallback(()=>{c.trim()&&(R?.(G??null,c.trim()),d(""),z(!1))},[c,G,R]),T=(k,A=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:A>0?16:0},children:k.map(O=>e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${O.id===G?" nice-wiki__tree-node--active":""}${O.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ie?.(O),role:"treeitem","aria-selected":O.id===G,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(u.NiceIcon,{name:O.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:O.title}),O.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:s("draft","Draft")})]}),O.children&&O.children.length>0&&T(O.children,A+1)]},O.id))});return y?null:e.jsxs("div",{ref:te,id:E,className:`nice-wiki nice-size-${g}${v?` ${v}`:""}${o?" nice-disabled":""}`,style:D,children:[!X&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:w},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??s("wiki","Wiki")}),h&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>h(!0),"aria-label":s("collapseSidebar","Collapse sidebar"),children:e.jsx(u.NiceIcon,{name:"chevron-left",size:16})})]}),f&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:L,onChange:k=>C(k.target.value),placeholder:s("searchPages","Search pages…"),disabled:o}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:T(q)}),R&&!r&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:b?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:k=>d(k.target.value),placeholder:s("pageTitle","Page title"),onKeyDown:k=>k.key==="Enter"&&S(),disabled:o}),e.jsx("button",{type:"button",disabled:o||!c.trim(),onClick:S,"aria-label":s("create","Create"),children:e.jsx(u.NiceIcon,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>z(!1),"aria-label":s("cancel","Cancel"),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>z(!0),disabled:o,children:[e.jsx(u.NiceIcon,{name:"plus",size:14})," ",s("newPage","New page")]})})]}),X&&h&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>h(!1),"aria-label":s("expandSidebar","Expand sidebar"),children:e.jsx(u.NiceIcon,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:$?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:$.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[I&&!r&&e.jsx("button",{type:"button",disabled:o,onClick:()=>I(!J),children:J?s("preview","Preview"):s("edit","Edit")}),p&&e.jsx("button",{type:"button",disabled:o,onClick:()=>p($.id),children:s("history","History")}),j&&!r&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:o,onClick:()=>j($.id),children:s("delete","Delete")})]})]}),$.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[$.updatedBy&&e.jsxs("span",{children:[s("lastEditedBy","Last edited by")," ",$.updatedBy]}),e.jsx("span",{children:new Date($.updatedAt).toLocaleDateString()})]}),J?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:P,onChange:k=>ee?.(k.target.value),disabled:o}),ae&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:o,onClick:()=>ae($.id,P),children:s("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:_==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:u.sanitizeHtml(P)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:P})})]}):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})]})});_n.displayName="NiceWiki";const $i=n.forwardRef(function(i,a){const{enableAI:o=!0,aiModel:r,enableInlineCompletion:g=!0,completionDelay:x=500,enableExplain:v=!0,enableRefactor:D=!0,enableGenerate:N=!0,systemPrompt:q,onExplain:G,onRefactor:P,showAIToolbar:_=!0,aiShortcutKey:J="Ctrl",language:ie="plaintext",value:ee,onChange:ae,...R}=i,j=n.useRef(null),[I,p]=n.useState(null),[w,X]=n.useState(!1),[h,f]=n.useState(""),[B,te]=n.useState(!1),[M,y]=n.useState(""),[s,E]=n.useState(""),[L,l]=n.useState(""),c=n.useRef(void 0),{t:d}=Qt.useNiceTranslation(),b=u.useNiceAI(),{complete:z,explain:$,refactor:C,generateFromComment:S,isLoading:T}=u.useCodeCompletion({language:ie,model:r}),k=o&&b.isConfigured,A=n.useCallback(async()=>{if(!k||!g||!j.current||!j.current.getEditor())return;const ye=j.current.getCursorPosition(),re=j.current.getValue().split(`
18
+ `),Q=re.slice(0,ye.lineNumber-1),de=re[ye.lineNumber-1]||"",F=[...Q,de.slice(0,ye.column-1)].join(`
19
+ `),H=[de.slice(ye.column-1),...re.slice(ye.lineNumber)].join(`
20
+ `);try{const U=await z(F,H);U&&p({lineNumber:ye.lineNumber,column:ye.column,text:U})}catch{}},[k,g,z]),O=n.useCallback(async()=>{if(!k||!v||!j.current)return"";const he=j.current.getSelection();if(!he)return"";l(he),X(!0),f("");try{const ye=await $(he);return f(ye),G?.(he,ye),ye}catch{return f(d("codeEditorAI.explanationFailed","Failed to explain code")),""}},[k,v,$,G,d]),ce=n.useCallback(async he=>{if(!k||!D||!j.current)return"";const ye=j.current.getSelection();if(!ye)return"";try{const xe=await C(ye,he);return E(xe),P?.(ye,xe),xe}catch{return""}},[k,D,C,P]),pe=n.useCallback(async()=>{if(!k||!N||!j.current)return;const he=j.current.getCursorPosition(),xe=j.current.getValue().split(`
21
+ `);let re="";for(let Q=he.lineNumber-1;Q>=0&&Q>=he.lineNumber-3;Q--){const de=xe[Q]?.trim()||"";if(de.startsWith("//")||de.startsWith("#")||de.startsWith("/*")||de.startsWith("*")){re=de.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(re)try{const Q=await S(re);Q&&j.current&&j.current.insertText(`
22
+ `+Q)}catch{}},[k,N,S]),ne=n.useCallback(()=>{!I||!j.current||(j.current.insertText(I.text),p(null))},[I]),je=n.useCallback(()=>{p(null)},[]),ve=n.useCallback(he=>{i.onCursorPositionChange?.(he),!(!k||!g)&&(c.current&&clearTimeout(c.current),p(null),c.current=setTimeout(()=>{A()},x))},[i.onCursorPositionChange,k,g,x,A]);n.useEffect(()=>{if(!j.current?.getEditor()||!k)return;const ye=xe=>{if(J==="Ctrl"&&xe.ctrlKey||J==="Alt"&&xe.altKey||J==="Meta"&&xe.metaKey){if(xe.key===" "&&g&&(xe.preventDefault(),A()),xe.key==="e"&&v&&(xe.preventDefault(),O()),xe.key==="r"&&D){xe.preventDefault();const Q=j.current?.getSelection();Q&&(l(Q),te(!0))}xe.key==="g"&&N&&(xe.preventDefault(),pe())}xe.key==="Tab"&&I&&(xe.preventDefault(),ne()),xe.key==="Escape"&&I&&je()};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},[k,J,g,v,D,N,A,O,pe,I,ne,je]),n.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const _e=n.useCallback(()=>{if(!s||!j.current)return;const he=j.current.getEditor();if(he?.executeEdits&&he?.getSelection){const ye=he.getSelection();he.executeEdits("ai-refactor",[{range:ye,text:s}])}te(!1),E(""),y("")},[s]);return n.useImperativeHandle(a,()=>({...j.current,getEditor:()=>j.current?.getEditor(),getMonaco:()=>j.current?.getMonaco(),focus:()=>j.current?.focus(),getValue:()=>j.current?.getValue()||"",setValue:he=>j.current?.setValue(he),getSelection:()=>j.current?.getSelection()||"",insertText:he=>j.current?.insertText(he),formatDocument:()=>j.current?.formatDocument(),goToLine:(he,ye)=>j.current?.goToLine(he,ye),findReplace:()=>j.current?.findReplace(),undo:()=>j.current?.undo(),redo:()=>j.current?.redo(),getCursorPosition:()=>j.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:he=>j.current?.setMarkers(he),triggerCompletion:A,explainSelection:O,refactorSelection:ce,generateFromComment:pe,acceptCompletion:ne,dismissCompletion:je})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[_&&k&&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"}),T&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:d("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:()=>A(),disabled:T,title:`${d("codeEditorAI.complete","Complete")} (${J}+Space)`,children:[e.jsx(u.NiceIcon,{name:"lightbulb",size:14})," ",d("codeEditorAI.complete","Complete")]}),v&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>O(),disabled:T,title:`${d("codeEditorAI.explain","Explain")} (${J}+E)`,children:[e.jsx(u.NiceIcon,{name:"book",size:14})," ",d("codeEditorAI.explain","Explain")]}),D&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const he=j.current?.getSelection();he&&(l(he),te(!0))},disabled:T,title:`${d("codeEditorAI.refactor","Refactor")} (${J}+R)`,children:[e.jsx(u.NiceIcon,{name:"settings",size:14})," ",d("codeEditorAI.refactor","Refactor")]}),N&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>pe(),disabled:T,title:`${d("codeEditorAI.generate","Generate")} (${J}+G)`,children:[e.jsx(u.NiceIcon,{name:"zap",size:14})," ",d("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(_t.NiceCodeEditor,{ref:j,value:ee,onChange:ae,language:ie,onCursorPositionChange:ve,...R}),I&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(I.lineNumber-1)*19}px + 4px)`,left:`calc(${(I.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:I.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",d("codeEditorAI.toAccept","to accept")]})]})]}),w&&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(u.NiceIcon,{name:"book",size:16})," ",d("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>X(!1),"aria-label":d("codeEditorAI.close","Close"),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:T?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:d("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:L}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:h||d("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),B&&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(u.NiceIcon,{name:"settings",size:16})," ",d("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{te(!1),E(""),y("")},"aria-label":d("codeEditorAI.close","Close"),children:e.jsx(u.NiceIcon,{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:L}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:d("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:M,onChange:he=>y(he.target.value),onKeyDown:he=>{he.key==="Enter"&&M&&ce(M)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>ce(M),disabled:T||!M,children:T?d("codeEditorAI.refactoring","Refactoring..."):d("codeEditorAI.refactor","Refactor")})]}),s&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:d("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:_e,children:[e.jsx(u.NiceIcon,{name:"check",size:14})," ",d("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{E(""),y("")},children:[e.jsx(u.NiceIcon,{name:"close",size:14})," ",d("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Ei(t){const i=t instanceof Date?t:new Date(t),a=(o,r=2)=>String(o).padStart(r,"0");return`${a(i.getHours())}:${a(i.getMinutes())}:${a(i.getSeconds())}.${a(i.getMilliseconds(),3)}`}function Ii(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const kn=n.forwardRef(function(i,a){const{entries:o,maxHeight:r=240,autoScroll:g=!0,showTimestamps:x=!0,levelFilter:v,onClear:D,title:N,emptyText:q="No output",clearLabel:G="Clear",fontFamily:P,className:_,style:J,id:ie,"data-testid":ee}=i,ae=n.useRef(null),R=n.useMemo(()=>{if(!v||v.length===0)return o;const p=new Set(v);return o.filter(w=>p.has(w.level??"log"))},[o,v]);n.useEffect(()=>{g&&ae.current&&(ae.current.scrollTop=ae.current.scrollHeight)},[R.length,g]);const j=!!N||!!D,I="nice-log-console"+(_?` ${_}`:"");return e.jsxs("div",{ref:a,id:ie,className:I,style:{...P?{fontFamily:P}:null,...J},"data-testid":ee,children:[j&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:N}),D&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:D,"aria-label":G,children:G})]}),e.jsx("div",{ref:ae,className:"nice-log-console__body",style:{maxHeight:typeof r=="number"?`${r}px`:r},role:"log","aria-live":"polite","aria-relevant":"additions",children:R.length===0?e.jsx("div",{className:"nice-log-console__empty",children:q}):R.map((p,w)=>{const X=p.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${X}`,children:[x&&p.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Ei(p.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:X}),p.source&&e.jsx("span",{className:"nice-log-console__source",children:p.source}),e.jsx("span",{className:"nice-log-console__message",children:p.message}),p.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Ii(p.data)})]},w)})})]})}),Ht="nice-log-console-styles";if(typeof document<"u"&&!document.getElementById(Ht)){const t=document.createElement("style");t.id=Ht,t.textContent=`
23
+ .nice-log-console {
24
+ display: flex;
25
+ flex-direction: column;
26
+ border: 1px solid var(--nice-border, #e0e0e0);
27
+ border-radius: var(--nice-radius-sm, 4px);
28
+ background: var(--nice-surface, #fff);
29
+ color: var(--nice-text-primary, #1f2937);
30
+ overflow: hidden;
31
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
32
+ font-size: 12px;
33
+ line-height: 1.55;
34
+ }
35
+ .nice-log-console__header {
36
+ display: flex;
37
+ align-items: center;
38
+ justify-content: space-between;
39
+ gap: var(--nice-space-2, 8px);
40
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
41
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
42
+ background: var(--nice-bg-secondary, #f5f5f5);
43
+ }
44
+ .nice-log-console__title {
45
+ font-weight: 600;
46
+ font-size: 12px;
47
+ }
48
+ .nice-log-console__clear {
49
+ border: 1px solid var(--nice-border, #e0e0e0);
50
+ background: var(--nice-surface, #fff);
51
+ color: var(--nice-text-secondary, #6b7280);
52
+ border-radius: var(--nice-radius-sm, 4px);
53
+ padding: 2px 8px;
54
+ font: inherit;
55
+ font-size: 11px;
56
+ cursor: pointer;
57
+ }
58
+ .nice-log-console__clear:hover {
59
+ color: var(--nice-text-primary, #1f2937);
60
+ border-color: var(--nice-border-color, #9ca3af);
61
+ }
62
+ .nice-log-console__body {
63
+ flex: 1;
64
+ overflow: auto;
65
+ padding: var(--nice-space-2, 8px);
66
+ }
67
+ .nice-log-console__empty {
68
+ color: var(--nice-text-muted, #9ca3af);
69
+ font-style: italic;
70
+ padding: var(--nice-space-2, 8px) 0;
71
+ }
72
+ .nice-log-console__entry {
73
+ display: flex;
74
+ flex-wrap: wrap;
75
+ align-items: baseline;
76
+ gap: var(--nice-space-2, 8px);
77
+ padding: 1px 0;
78
+ white-space: pre-wrap;
79
+ word-break: break-word;
80
+ }
81
+ .nice-log-console__time {
82
+ color: var(--nice-text-muted, #9ca3af);
83
+ flex: 0 0 auto;
84
+ }
85
+ .nice-log-console__level {
86
+ flex: 0 0 auto;
87
+ text-transform: uppercase;
88
+ font-size: 10px;
89
+ font-weight: 700;
90
+ letter-spacing: 0.04em;
91
+ opacity: 0.8;
92
+ min-width: 38px;
93
+ }
94
+ .nice-log-console__source {
95
+ flex: 0 0 auto;
96
+ color: var(--nice-primary, #2563eb);
97
+ }
98
+ .nice-log-console__message {
99
+ flex: 1 1 auto;
100
+ }
101
+ .nice-log-console__data {
102
+ flex: 1 0 100%;
103
+ margin: 2px 0 4px;
104
+ padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
105
+ background: var(--nice-bg-secondary, #f5f5f5);
106
+ border-radius: var(--nice-radius-sm, 4px);
107
+ overflow: auto;
108
+ font: inherit;
109
+ }
110
+ .nice-log-console__entry--info .nice-log-console__level { color: var(--nice-primary, #2563eb); }
111
+ .nice-log-console__entry--warn { color: var(--nice-warning-text, #92400e); }
112
+ .nice-log-console__entry--warn .nice-log-console__level { color: var(--nice-warning, #d97706); }
113
+ .nice-log-console__entry--error { color: var(--nice-danger, #dc2626); }
114
+ .nice-log-console__entry--error .nice-log-console__level { color: var(--nice-danger, #dc2626); }
115
+ .nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
116
+ .nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
117
+ .nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
118
+ `,document.head.appendChild(t)}const Mi=[{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 Ot(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ft(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 Ti(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ri=n.forwardRef(function(i,a){const{value:o,defaultValue:r,onChange:g,language:x="javascript",onRun:v,input:D,onInputChange:N,showInputPanel:q,extraLibs:G,height:P=260,running:_,autoRun:J=!1,autoRunDelay:ie=600,layout:ee="vertical",runLabel:ae="Run",theme:R="auto",tutorial:j,className:I,style:p,id:w,"data-testid":X}=i,[h,f]=u.useControllableState({value:o,defaultValue:r,fallbackValue:"",onChange:g,componentName:"NiceScriptRunner"}),B=q??D!==void 0,[te,M]=n.useState(()=>Ot(D)),[y,s]=n.useState(null),[E,L]=n.useState(!1),[l,c]=n.useState(null),d=_??E,b=R==="light"?"vs":R==="dark"?"vs-dark":R;n.useEffect(()=>{M(Ot(D))},[D]);const z=n.useCallback(async()=>{const k=Ft(te),A=typeof performance<"u"?performance.now():Date.now();_===void 0&&L(!0);try{const O=await v(h,k.value),ce=O.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-A);c({...O,durationMs:ce})}catch(O){c({ok:!1,error:O instanceof Error?O.message:String(O),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-A)})}finally{_===void 0&&L(!1)}},[te,v,h,_]),$=n.useRef(z);$.current=z,n.useEffect(()=>{if(!J)return;const k=setTimeout(()=>{$.current()},ie);return()=>clearTimeout(k)},[J,ie,h,te]);const C=n.useCallback(k=>{M(k);const A=Ft(k);s(A.error),N?.(A.value)},[N]),S=typeof P=="number"?`${P}px`:P,T=`nice-script-runner nice-script-runner--${ee}`+(I?` ${I}`:"");return e.jsxs("div",{ref:a,id:w,className:T,style:p,"data-testid":X,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void z(),disabled:d,children:[d?"…":e.jsx(u.NiceIcon,{name:"play",size:14})," ",ae]}),l?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(l.ok?"ok":"error"),children:l.ok?"OK":"Failed"}),e.jsxs("span",{className:"nice-script-runner__duration",children:[l.durationMs," ms"]})]}),j&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(j,Mi)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(_t.NiceCodeEditor,{value:h,onChange:f,language:x,theme:b,height:S,extraLibs:G,options:{minimap:!1}}),B&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:["Input (JSON)",y&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",y]})]}),e.jsx(_t.NiceCodeEditor,{value:te,onChange:C,language:"json",theme:b,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[l?.error&&e.jsx("div",{className:"nice-script-runner__error",children:l.error}),l&&l.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:Ti(l.result)})]}),e.jsx(kn,{title:"Logs",entries:l?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Kt="nice-script-runner-styles";if(typeof document<"u"&&!document.getElementById(Kt)){const t=document.createElement("style");t.id=Kt,t.textContent=`
119
+ .nice-script-runner {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: var(--nice-space-2, 8px);
123
+ border: 1px solid var(--nice-border, #e0e0e0);
124
+ border-radius: var(--nice-radius-md, 6px);
125
+ padding: var(--nice-space-2, 8px);
126
+ background: var(--nice-surface, #fff);
127
+ }
128
+ .nice-script-runner__toolbar {
129
+ display: flex;
130
+ align-items: center;
131
+ gap: var(--nice-space-2, 8px);
132
+ }
133
+ .nice-script-runner__run {
134
+ border: 0;
135
+ background: var(--nice-primary, #2563eb);
136
+ color: var(--nice-text-inverse, #fff);
137
+ border-radius: var(--nice-radius-sm, 4px);
138
+ padding: 6px 14px;
139
+ font: inherit;
140
+ font-weight: 600;
141
+ cursor: pointer;
142
+ }
143
+ .nice-script-runner__run:disabled {
144
+ opacity: 0.6;
145
+ cursor: default;
146
+ }
147
+ .nice-script-runner__status {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ gap: var(--nice-space-2, 8px);
151
+ font-size: 12px;
152
+ }
153
+ .nice-script-runner__badge {
154
+ padding: 1px 8px;
155
+ border-radius: 999px;
156
+ font-size: 11px;
157
+ font-weight: 700;
158
+ }
159
+ .nice-script-runner__badge--ok {
160
+ background: var(--nice-success-bg, #dcfce7);
161
+ color: var(--nice-success-text, #166534);
162
+ }
163
+ .nice-script-runner__badge--error {
164
+ background: var(--nice-danger-bg, #fee2e2);
165
+ color: var(--nice-danger-text, #991b1b);
166
+ }
167
+ .nice-script-runner__duration {
168
+ color: var(--nice-text-muted, #9ca3af);
169
+ }
170
+ .nice-script-runner__panes {
171
+ display: grid;
172
+ gap: var(--nice-space-2, 8px);
173
+ }
174
+ .nice-script-runner--horizontal .nice-script-runner__panes {
175
+ grid-template-columns: 1fr 1fr;
176
+ }
177
+ .nice-script-runner__editors,
178
+ .nice-script-runner__output {
179
+ display: flex;
180
+ flex-direction: column;
181
+ gap: var(--nice-space-2, 8px);
182
+ min-width: 0;
183
+ }
184
+ .nice-script-runner__pane-label {
185
+ font-size: 11px;
186
+ font-weight: 600;
187
+ text-transform: uppercase;
188
+ letter-spacing: 0.04em;
189
+ color: var(--nice-text-secondary, #6b7280);
190
+ }
191
+ .nice-script-runner__input-error {
192
+ color: var(--nice-danger, #dc2626);
193
+ text-transform: none;
194
+ font-weight: 400;
195
+ }
196
+ .nice-script-runner__error {
197
+ padding: var(--nice-space-2, 8px);
198
+ border-radius: var(--nice-radius-sm, 4px);
199
+ background: var(--nice-danger-bg, #fee2e2);
200
+ color: var(--nice-danger-text, #991b1b);
201
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
202
+ font-size: 12px;
203
+ white-space: pre-wrap;
204
+ }
205
+ .nice-script-runner__result-body {
206
+ margin: 4px 0 0;
207
+ padding: var(--nice-space-2, 8px);
208
+ border: 1px solid var(--nice-border, #e0e0e0);
209
+ border-radius: var(--nice-radius-sm, 4px);
210
+ background: var(--nice-bg-secondary, #f9fafb);
211
+ max-height: 200px;
212
+ overflow: auto;
213
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
214
+ font-size: 12px;
215
+ }
216
+ `,document.head.appendChild(t)}const Ai=[{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"}],Di=n.forwardRef(function(i,a){const{value:o,defaultValue:r,onChange:g,allowSecret:x=!1,allowToggle:v=!1,allowDescription:D=!1,keySuggestions:N,keyPlaceholder:q="Key",valuePlaceholder:G="Value",addLabel:P="Add",readOnly:_=!1,duplicateKeyWarning:J=!0,tutorial:ie,className:ee,style:ae,id:R,"data-testid":j}=i,[I,p]=u.useControllableState({value:o,defaultValue:r,fallbackValue:[],onChange:g,componentName:"NiceKeyValueEditor"}),w=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),X=n.useMemo(()=>{const M=new Map,y=new Set;if(J){for(const s of I){const E=s.key.trim();E!==""&&M.set(E,(M.get(E)??0)+1)}M.forEach((s,E)=>{s>1&&y.add(E)})}return y},[I,J]),h=(M,y)=>{p(I.map((s,E)=>E===M?{...s,...y}:s))},f=M=>{p(I.filter((y,s)=>s!==M))},B=()=>{p([...I,{key:"",value:"",type:"text",enabled:!0}])},te="nice-key-value-editor"+(ee?` ${ee}`:"");return e.jsxs("div",{ref:a,id:R,className:te,style:{position:"relative",...ae},"data-testid":j,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(ie,Ai)})}),N&&N.length>0&&e.jsx("datalist",{id:w,children:N.map(M=>e.jsx("option",{value:M},M))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:I.map((M,y)=>{const s=M.type==="secret",E=M.key.trim()!==""&&X.has(M.key.trim()),L=v&&M.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(L?" nice-key-value-editor__row--disabled":""),children:[v&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:M.enabled!==!1,onChange:l=>h(y,{enabled:l.target.checked}),disabled:_,"aria-label":"Enabled"}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(E?" nice-key-value-editor__key--dup":""),value:M.key,list:N?w:void 0,placeholder:q,onChange:l=>h(y,{key:l.target.value}),readOnly:_,"aria-label":q,title:E?"Duplicate key":void 0}),e.jsx("input",{type:s?"password":"text",className:"nice-key-value-editor__value",value:M.value,placeholder:G,onChange:l=>h(y,{value:l.target.value}),readOnly:_,autoComplete:s?"new-password":"off","aria-label":G}),x&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(s?" nice-key-value-editor__secret--on":""),onClick:()=>h(y,{type:s?"text":"secret"}),disabled:_,title:s?"Secret (click to reveal as text)":"Mark as secret","aria-pressed":s,"aria-label":"Toggle secret",children:e.jsx(u.NiceIcon,{name:"lock",size:16})}),D&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:M.description??"",placeholder:"Description",onChange:l=>h(y,{description:l.target.value}),readOnly:_,"aria-label":"Description"}),!_&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>f(y),title:"Remove row","aria-label":"Remove row",children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},M.id??y)})}),!_&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:B,children:["+ ",P]})]})}),Ut="nice-key-value-editor-styles";if(typeof document<"u"&&!document.getElementById(Ut)){const t=document.createElement("style");t.id=Ut,t.textContent=`
217
+ .nice-key-value-editor {
218
+ display: flex;
219
+ flex-direction: column;
220
+ gap: var(--nice-space-2, 8px);
221
+ }
222
+ .nice-key-value-editor__rows {
223
+ display: flex;
224
+ flex-direction: column;
225
+ gap: var(--nice-space-1, 4px);
226
+ }
227
+ .nice-key-value-editor__row {
228
+ display: flex;
229
+ align-items: center;
230
+ gap: var(--nice-space-1, 4px);
231
+ }
232
+ .nice-key-value-editor__row--disabled {
233
+ opacity: 0.55;
234
+ }
235
+ .nice-key-value-editor__key,
236
+ .nice-key-value-editor__value,
237
+ .nice-key-value-editor__desc {
238
+ flex: 1 1 0;
239
+ min-width: 0;
240
+ padding: 6px 8px;
241
+ border: 1px solid var(--nice-border, #d1d5db);
242
+ border-radius: var(--nice-radius-sm, 4px);
243
+ background: var(--nice-bg, #fff);
244
+ color: var(--nice-text-primary, #1f2937);
245
+ font: inherit;
246
+ font-size: 13px;
247
+ }
248
+ .nice-key-value-editor__key {
249
+ flex-basis: 30%;
250
+ font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
251
+ }
252
+ .nice-key-value-editor__key--dup {
253
+ border-color: var(--nice-danger, #dc2626);
254
+ background: var(--nice-danger-bg, #fee2e2);
255
+ }
256
+ .nice-key-value-editor__key:focus,
257
+ .nice-key-value-editor__value:focus,
258
+ .nice-key-value-editor__desc:focus {
259
+ outline: none;
260
+ border-color: var(--nice-primary, #2563eb);
261
+ }
262
+ .nice-key-value-editor__toggle {
263
+ flex: 0 0 auto;
264
+ }
265
+ .nice-key-value-editor__secret,
266
+ .nice-key-value-editor__remove {
267
+ flex: 0 0 auto;
268
+ border: 1px solid var(--nice-border, #d1d5db);
269
+ background: var(--nice-surface, #fff);
270
+ border-radius: var(--nice-radius-sm, 4px);
271
+ padding: 5px 8px;
272
+ font-size: 13px;
273
+ line-height: 1;
274
+ cursor: pointer;
275
+ }
276
+ .nice-key-value-editor__secret--on {
277
+ border-color: var(--nice-warning, #d97706);
278
+ background: var(--nice-warning-bg, #fef3c7);
279
+ }
280
+ .nice-key-value-editor__remove:hover {
281
+ border-color: var(--nice-danger, #dc2626);
282
+ color: var(--nice-danger, #dc2626);
283
+ }
284
+ .nice-key-value-editor__add {
285
+ align-self: flex-start;
286
+ border: 1px dashed var(--nice-border, #d1d5db);
287
+ background: transparent;
288
+ color: var(--nice-primary, #2563eb);
289
+ border-radius: var(--nice-radius-sm, 4px);
290
+ padding: 5px 12px;
291
+ font: inherit;
292
+ font-size: 13px;
293
+ font-weight: 600;
294
+ cursor: pointer;
295
+ }
296
+ .nice-key-value-editor__add:hover {
297
+ background: var(--nice-bg-secondary, #f5f5f5);
298
+ }
299
+ `,document.head.appendChild(t)}const zi=["street","streetNumber","apartment","city","postalCode","state","country"],dt={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},wn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",name:v,id:D,className:N,style:q,accessMode:G,value:P={},onChange:_,fields:J=zi,placeholders:ie={},countries:ee,layout:ae="vertical",countryFirst:R=!1,validatePostalCode:j},I)=>{const p=u.useNiceAccessMode(G,D),w=p==="hidden";p==="disabled"&&(r=!0),p==="readOnly"&&(g=!0);const{t:X}=u.useNiceTranslation(),h=u.useControlId(D),f=n.useCallback((y,s)=>{_?.({...P,[y]:s})},[P,_]),B=n.useMemo(()=>{if(j&&P.postalCode)return j(P.postalCode,P.country)},[j,P.postalCode,P.country]),te=n.useMemo(()=>R&&J.includes("country")?["country",...J.filter(y=>y!=="country")]:J,[J,R]),M=`nice-address nice-address--${ae} nice-size-${x}`;return w?null:e.jsxs("div",{ref:I,id:h,className:`${M}${N?` ${N}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:q,role:"group","aria-label":t??X("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:te.map(y=>y==="country"&&ee?e.jsxs("div",{className:`nice-address__field nice-address__field--${y}`,children:[e.jsx("label",{className:"nice-address__field-label",children:X(y,dt[y])}),e.jsxs("select",{className:"nice-input nice-select",value:P.country??"",onChange:s=>f("country",s.target.value),disabled:r,"aria-label":X(y,dt[y]),children:[e.jsx("option",{value:"",children:ie.country??X("selectCountry","— Select country —")}),ee.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:X(y,dt[y])}),e.jsx("input",{className:`nice-input${y==="postalCode"&&B?" nice-input--error":""}`,type:"text",name:v?`${v}.${y}`:y,value:P[y]??"",onChange:s=>f(y,s.target.value),placeholder:ie[y]??"",disabled:r,readOnly:g,"aria-label":X(y,dt[y])}),y==="postalCode"&&B&&e.jsx("span",{className:"nice-error-text",children:B})]},y))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),a&&typeof a=="string"&&e.jsx("span",{className:"nice-error-text",children:a})]})});wn.displayName="NiceAddressInput";const Li={asset:"var(--nice-color-info, #5bc0de)",liability:"var(--nice-color-warning, #f0ad4e)",equity:"var(--nice-color-success, #5cb85c)",revenue:"var(--nice-color-primary, #337ab7)",expense:"var(--nice-color-error, #d9534f)"},Nn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",name:v,id:D,className:N,style:q,accessMode:G,value:P,onChange:_,accounts:J,treeView:ie=!1,placeholder:ee,searchable:ae=!0,showType:R=!0,onSearch:j},I)=>{const p=u.useNiceAccessMode(G,D),w=p==="hidden";p==="disabled"&&(r=!0),p==="readOnly"&&(g=!0);const{t:X}=u.useNiceTranslation(),h=u.useControlId(D),[f,B]=n.useState(""),[te,M]=n.useState(!1),y=n.useMemo(()=>{const c=d=>{for(const b of d){if(b.code===P)return b;if(b.children){const z=c(b.children);if(z)return z}}};return c(J)},[J,P]),s=n.useMemo(()=>{const c=[],d=b=>{for(const z of b)c.push(z),z.children&&d(z.children)};return d(J),c},[J]),E=n.useMemo(()=>{if(!f)return s;const c=f.toLowerCase();return s.filter(d=>d.code.toLowerCase().includes(c)||d.name.toLowerCase().includes(c))},[s,f]),L=n.useCallback(c=>{B(c),j?.(c),M(!0)},[j]),l=n.useCallback(c=>{_?.(c.code,c),M(!1),B("")},[_]);return w?null:e.jsxs("div",{ref:I,id:h,className:`nice-account-picker nice-size-${x}${N?` ${N}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:q,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${h}-input`,children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:ae&&!g?e.jsx("input",{id:`${h}-input`,className:"nice-input",type:"text",value:te?f:y?`${y.code} — ${y.name}`:"",onChange:c=>L(c.target.value),onFocus:()=>{B(""),M(!0)},onBlur:()=>setTimeout(()=>M(!1),200),placeholder:ee??X("searchAccount","Search account…"),disabled:r,required:o}):e.jsx("div",{className:"nice-account-picker__display",children:y?`${y.code} — ${y.name}`:ee??X("selectAccount","Select account…")})}),te&&E.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:E.map(c=>e.jsxs("div",{className:`nice-account-picker__option${c.code===P?" nice-account-picker__option--selected":""}${c.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":c.code===P,onClick:()=>l(c),children:[R&&c.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Li[c.type]},title:c.type,children:e.jsx(u.NiceIcon,{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})]})});Nn.displayName="NiceAccountPicker";const Cn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",name:v,id:D,className:N,style:q,accessMode:G,value:P=[],onChange:_,contacts:J=[],onSearch:ie,searchDelay:ee=300,multiple:ae=!1,placeholder:R,onContactClick:j,maxSelections:I},p)=>{const w=u.useNiceAccessMode(G,D),X=w==="hidden";w==="disabled"&&(r=!0),w==="readOnly"&&(g=!0);const{t:h}=u.useNiceTranslation(),f=u.useControlId(D),[B,te]=n.useState(""),[M,y]=n.useState([]),[s,E]=n.useState(!1),[L,l]=n.useState(!1),c=n.useMemo(()=>{const $=[...J,...M],C=new Map($.map(S=>[S.id,S]));return P.map(S=>C.get(S)).filter(Boolean)},[P,J,M]),d=n.useCallback($=>{if(te($),$.length<1){y([]),E(!1);return}if(ie){l(!0);const T=setTimeout(async()=>{const k=await ie($);y(k),E(!0),l(!1)},ee);return()=>clearTimeout(T)}const C=$.toLowerCase(),S=J.filter(T=>T.name.toLowerCase().includes(C)||T.email?.toLowerCase().includes(C)||T.phone?.includes($));y(S),E(!0)},[ie,J,ee]),b=n.useCallback($=>{if(ae)if(P.includes($.id))_?.(P.filter(C=>C!==$.id));else{if(I&&P.length>=I)return;_?.([...P,$.id])}else _?.([$.id]),E(!1),te("")},[P,_,ae,I]),z=n.useCallback($=>{_?.(P.filter(C=>C!==$))},[P,_]);return X?null:e.jsxs("div",{ref:p,id:f,className:`nice-contact-picker nice-size-${x}${N?` ${N}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:q,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($=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>j?.($),children:[$.avatarUrl&&e.jsx("img",{src:$.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:$.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:C=>{C.stopPropagation(),z($.id)},disabled:r,"aria-label":h("controls.remove","Remove"),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},$.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:B,onChange:$=>d($.target.value),onFocus:()=>B.length>0&&E(!0),onBlur:()=>setTimeout(()=>E(!1),200),placeholder:R??h("searchContacts","Search contacts…"),disabled:r,"aria-label":h("searchContacts","Search contacts")}),L&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(u.NiceIcon,{name:"refresh",size:16})})]}),s&&M.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:M.map($=>e.jsxs("div",{className:`nice-contact-picker__option${P.includes($.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":P.includes($.id),onClick:()=>b($),children:[$.avatarUrl&&e.jsx("img",{src:$.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:$.name}),$.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:$.subtitle}),$.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:$.email})]}),$.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(u.NiceIcon,{name:$.type==="person"?"user":"building",size:16})})]},$.id))}),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="NiceContactPicker";const Pi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Yt={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"},vt=["","🏻","🏼","🏽","🏾","🏿"],ht=[{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"}],Xt="nice-emoji-picker-recent",Sn=({onSelect:t,showSearch:i=!0,searchPlaceholder:a,showSkinTones:o=!0,defaultSkinTone:r=0,showRecent:g=!0,maxRecent:x=24,recentEmojis:v,onRecentChange:D,categories:N,customEmojis:q=[],columns:G=8,size:P="md",className:_="",style:J,"data-testid":ie="nice-emoji-picker"})=>{const{t:ee}=u.useNiceTranslation(),[ae,R]=n.useState(""),[j,I]=n.useState(g?"recent":"smileys"),[p,w]=n.useState(r),[X,h]=n.useState(!1),f=n.useRef(null),[B,te]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Xt)||"[]")}catch{return[]}}),M=v??B,y=N??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],s=n.useMemo(()=>{if(!ae)return ht;const b=ae.toLowerCase();return ht.filter(z=>z.name.toLowerCase().includes(b)||z.emoji.includes(b)||z.keywords?.some($=>$.toLowerCase().includes(b)))},[ae]),E=n.useMemo(()=>{const b={};for(const z of y)z==="recent"?b[z]=M.map($=>ht.find(C=>C.emoji===$)).filter($=>$!==void 0).slice(0,x):b[z]=s.filter($=>$.category===z);return b},[y,s,M,x]),L=n.useCallback((b,z)=>!z||p===0?b:b.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+vt[p],[p]),l=n.useCallback(b=>{const z=L(b.emoji,b.skinTones),$=[b.emoji,...M.filter(C=>C!==b.emoji)].slice(0,x);if(v===void 0){te($);try{localStorage.setItem(Xt,JSON.stringify($))}catch{}}D?.($),t?.(z,b)},[L,M,x,v,D,t]),c=n.useCallback(b=>{t?.(`:${b.name}:`,b)},[t]);n.useEffect(()=>{if(!X)return;const b=z=>{f.current&&!f.current.contains(z.target)&&h(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[X]);const d=ae?s:E[j]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${P} ${_}`,style:J,"data-testid":ie,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:ae,onChange:b=>R(b.target.value),placeholder:a??ee("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${ie}-search`}),o&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:f,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>h(!X),title:ee("skinTone","Skin tone"),children:["✋",vt[p]]}),X&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:vt.map((b,z)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${z===p?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{w(z),h(!1)},children:["✋",b]},z))})]})]}),!ae&&e.jsx("div",{className:"nice-emoji-picker__categories",role:"tablist",children:y.map(b=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${j===b?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>I(b),title:Yt[b],role:"tab","aria-selected":j===b,children:Pi[b]},b))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[ae?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${G}, 1fr)`},children:s.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ee("noEmojis","No emojis found")}):s.map((b,z)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>l(b),title:b.name,children:L(b.emoji,b.skinTones)},`${b.emoji}-${z}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Yt[j]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${G}, 1fr)`},children:d.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:j==="recent"?ee("noRecent","No recent emojis"):ee("noEmojis","No emojis")}):d.map((b,z)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>l(b),title:b.name,children:L(b.emoji,b.skinTones)},`${b.emoji}-${z}`))})]}),q.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ee("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${G}, 1fr)`},children:q.map(b=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>c(b),title:b.name,children:e.jsx("img",{src:b.url,alt:b.name})},b.id))})]})]})]})};Sn.displayName="NiceEmojiPicker";const $n=n.forwardRef(({length:t=6,value:i="",onChange:a,masked:o=!1,onComplete:r,label:g,helperText:x,error:v,required:D,disabled:N,readOnly:q,size:G="md",name:P,id:_,className:J,style:ie,autoFocus:ee,labelPlacement:ae,errorPlacement:R,labelWidth:j,controlWidth:I,loading:p,cellWidth:w,...X},h)=>{const f=u.useControlId(_),B=n.useRef([]),te=i.padEnd(t,"").slice(0,t).split(""),M=n.useCallback(l=>{const c=Math.max(0,Math.min(t-1,l));B.current[c]?.focus()},[t]),y=n.useCallback(l=>{const c=l.join("");a?.(c),c.length===t&&c.indexOf("")===-1&&/^\d+$/.test(c)&&r?.(c)},[a,r,t]),s=n.useCallback((l,c)=>{const b=c.target.value.replace(/\D/g,"").slice(-1);if(!b)return;const z=[...te];z[l]=b,y(z),M(l+1)},[te,y,M]),E=n.useCallback((l,c)=>{if(c.key==="Backspace"){c.preventDefault();const d=[...te];te[l]?(d[l]="",y(d)):l>0&&(d[l-1]="",y(d),M(l-1))}else c.key==="ArrowLeft"?(c.preventDefault(),M(l-1)):c.key==="ArrowRight"&&(c.preventDefault(),M(l+1))},[te,y,M]),L=n.useCallback(l=>{l.preventDefault();const c=l.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!c)return;const d=c.padEnd(t,"").slice(0,t).split("");for(let b=c.length;b<t;b++)d[b]=te[b]||"";y(d),M(Math.min(c.length,t-1))},[t,te,y,M]);return e.jsxs("div",{className:`nice-field nice-field--${G} nice-field--otp${ae?` nice-field--label-${ae}`:""}${R==="right"?" nice-field--error-right":""} ${p?"nice-field--loading":""} ${J||""}`,style:{...ie,...j!=null&&{"--nice-field-label-width":typeof j=="number"?`${j}px`:j},...I!=null&&{"--nice-field-control-width":typeof I=="number"?`${I}px`:I},...w!=null&&{"--nice-otp-cell-width":typeof w=="number"?`${w}px`:w}},"aria-busy":p||void 0,...X,children:[g&&e.jsx("label",{htmlFor:`${f}-0`,className:`nice-field__label ${D?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:h,className:`nice-otp nice-otp--${G} ${v?"nice-otp--error":""} ${N?"nice-otp--disabled":""}`,onPaste:L,children:[Array.from({length:t},(l,c)=>e.jsx("input",{ref:d=>{B.current[c]=d},id:c===0?`${f}-0`:void 0,className:"nice-otp__digit",type:o?"password":"text",inputMode:"numeric",maxLength:2,value:te[c]||"",disabled:N,readOnly:q,autoFocus:ee&&c===0,"aria-invalid":!!v,"aria-label":`${c+1}`,onChange:d=>s(c,d),onKeyDown:d=>E(c,d),onFocus:d=>d.target.select()},c)),P&&e.jsx("input",{type:"hidden",name:P,value:i})]}),R==="right"&&v&&e.jsx("div",{id:`${f}-error`,className:"nice-field__error",role:"alert",children:v}),R==="right"&&!v&&x&&e.jsx("div",{id:`${f}-helper`,className:"nice-field__helper",children:x}),p&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),R!=="right"&&v&&e.jsx("div",{id:`${f}-error`,className:"nice-field__error",role:"alert",children:v}),R!=="right"&&!v&&x&&e.jsx("div",{id:`${f}-helper`,className:"nice-field__helper",children:x})]})});$n.displayName="NiceInputOtp";const Bi=[{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"}],qt={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Hi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],En=n.forwardRef(({src:t,size:i="md",editorSize:a="standard",tools:o=Hi,showToolbar:r=!0,showZoom:g=!0,maxUndo:x=30,onSave:v,onCancel:D,onChange:N,width:q="100%",height:G=500,tutorial:P,className:_,style:J,id:ie,...ee},ae)=>{const R=u.useControlId(ie),{t:j}=u.useNiceTranslation(),I=n.useRef(null),p=n.useRef(null),[w,X]=n.useState({...qt}),[h,f]=n.useState(null),[B,te]=n.useState(!1),[M,y]=n.useState(1),[s,E]=n.useState("rect"),[L,l]=n.useState("var(--nice-danger, #ff0000)"),[c,d]=n.useState({w:0,h:0}),[b,z]=n.useState([]),[$,C]=n.useState([]),[S,T]=n.useState(null),[k,A]=n.useState(null),[O,ce]=n.useState(null),pe=n.useCallback(H=>{z(U=>[...U.slice(-(x-1)),H]),C([])},[x]),ne=n.useCallback(H=>{X(U=>{pe(U);const ge={...U,...H};return N?.(ge),ge})},[N,pe]),je=n.useCallback(()=>{if(b.length===0)return;const H=b[b.length-1];z(U=>U.slice(0,-1)),C(U=>[...U,w]),X(H),N?.(H)},[b,w,N]),ve=n.useCallback(()=>{if($.length===0)return;const H=$[$.length-1];C(U=>U.slice(0,-1)),z(U=>[...U,w]),X(H),N?.(H)},[$,w,N]);n.useEffect(()=>{const H=new Image;H.crossOrigin="anonymous",H.onload=()=>{p.current=H,d({w:H.width,h:H.height}),te(!0)},H.src=t},[t]),n.useEffect(()=>{if(!B||!I.current||!p.current)return;const H=I.current,U=H.getContext("2d");if(!U)return;const ge=p.current,le=w.rotation%180!==0,K=le?ge.height:ge.width,Z=le?ge.width:ge.height;H.width=K,H.height=Z,U.clearRect(0,0,K,Z),U.save(),U.filter=`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,U.translate(K/2,Z/2),U.rotate(w.rotation*Math.PI/180),U.scale(w.flipH?-1:1,w.flipV?-1:1),U.drawImage(ge,-ge.width/2,-ge.height/2),U.restore(),w.annotations.forEach(Y=>{switch(U.save(),U.strokeStyle=Y.color??"red",U.fillStyle=Y.color??"red",U.lineWidth=Y.strokeWidth??2,U.font=`${Y.fontSize??16}px sans-serif`,Y.type){case"text":U.fillText(Y.text??"",Y.x,Y.y);break;case"rect":U.strokeRect(Y.x,Y.y,Y.width??100,Y.height??50);break;case"circle":{const oe=(Y.width??50)/2,me=(Y.height??50)/2;U.beginPath(),U.ellipse(Y.x+oe,Y.y+me,oe,me,0,0,Math.PI*2),U.stroke();break}case"line":U.beginPath(),U.moveTo(Y.x,Y.y),U.lineTo(Y.x+(Y.width??100),Y.y+(Y.height??0)),U.stroke();break;case"arrow":{const oe=Y.x+(Y.width??100),me=Y.y+(Y.height??0);U.beginPath(),U.moveTo(Y.x,Y.y),U.lineTo(oe,me),U.stroke();const be=Math.atan2(me-Y.y,oe-Y.x),we=10;U.beginPath(),U.moveTo(oe,me),U.lineTo(oe-we*Math.cos(be-.4),me-we*Math.sin(be-.4)),U.lineTo(oe-we*Math.cos(be+.4),me-we*Math.sin(be+.4)),U.closePath(),U.fill();break}}U.restore()}),k&&(U.save(),U.fillStyle=u.resolveCssColor("var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",U.canvas),U.fillRect(0,0,K,Z),U.clearRect(k.x,k.y,k.w,k.h),U.strokeStyle=u.resolveCssColor("var(--nice-bg-primary, #fff)",U.canvas),U.lineWidth=2,U.setLineDash([5,5]),U.strokeRect(k.x,k.y,k.w,k.h),U.restore())},[B,w,k]);const _e=n.useCallback(H=>{if(!I.current)return;const U=I.current.getBoundingClientRect(),ge=I.current.width/U.width,le=I.current.height/U.height,K=(H.clientX-U.left)*ge,Z=(H.clientY-U.top)*le;h==="crop"?T({startX:K,startY:Z}):h==="annotate"&&ce({startX:K,startY:Z})},[h]),he=n.useCallback(H=>{if(!I.current)return;const U=I.current.getBoundingClientRect(),ge=I.current.width/U.width,le=I.current.height/U.height,K=(H.clientX-U.left)*ge,Z=(H.clientY-U.top)*le;S&&A({x:Math.min(S.startX,K),y:Math.min(S.startY,Z),w:Math.abs(K-S.startX),h:Math.abs(Z-S.startY)})},[S]),ye=n.useCallback(H=>{if(S&&k&&k.w>5&&k.h>5&&ne({crop:{x:k.x,y:k.y,width:k.w,height:k.h}}),T(null),O&&I.current){const U=I.current.getBoundingClientRect(),ge=I.current.width/U.width,le=I.current.height/U.height,K=(H.clientX-U.left)*ge,Z=(H.clientY-U.top)*le,Y=K-O.startX,oe=Z-O.startY;if(Math.abs(Y)>3||Math.abs(oe)>3||s==="text"){const me={type:s,x:O.startX,y:O.startY,width:Math.abs(Y)||100,height:Math.abs(oe)||50,color:L,strokeWidth:2,text:s==="text"?prompt(j("imageEditor.annotationText","Text:"))??"":void 0};ne({annotations:[...w.annotations,me]})}ce(null)}},[S,k,O,s,L,w.annotations,ne,j]),xe=n.useCallback(()=>{if(!w.crop||!I.current)return;const H=I.current,U=H.getContext("2d");if(!U)return;const{x:ge,y:le,width:K,height:Z}=w.crop,Y=U.getImageData(ge,le,K,Z);H.width=K,H.height=Z,U.putImageData(Y,0,0),A(null),f(null)},[w.crop]),re=n.useCallback(()=>{if(!I.current)return;const H=I.current.toDataURL("image/png");v?.(H,w)},[v,w]),Q=n.useCallback(()=>{X({...qt}),A(null),f(null)},[]);n.useMemo(()=>`brightness(${w.brightness}%) contrast(${w.contrast}%) saturate(${w.saturate}%) blur(${w.blur}px)`,[w.brightness,w.contrast,w.saturate,w.blur]);const de=r?e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:je,disabled:b.length===0,title:j("imageEditor.undo","Undo"),"aria-label":j("imageEditor.undo","Undo"),children:e.jsx(u.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ve,disabled:$.length===0,title:j("imageEditor.redo","Redo"),"aria-label":j("imageEditor.redo","Redo"),children:e.jsx(u.NiceIcon,{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:()=>ne({rotation:(w.rotation-90+360)%360}),title:j("imageEditor.rotateLeft","Rotate left"),"aria-label":j("imageEditor.rotateLeft","Rotate left"),children:e.jsx(u.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({rotation:(w.rotation+90)%360}),title:j("imageEditor.rotateRight","Rotate right"),"aria-label":j("imageEditor.rotateRight","Rotate right"),children:e.jsx(u.NiceIcon,{name:"forward",size:16})})]}),o.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({flipH:!w.flipH}),title:j("imageEditor.flipH","Flip horizontal"),"aria-label":j("imageEditor.flipH","Flip horizontal"),children:e.jsx(u.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({flipV:!w.flipV}),title:j("imageEditor.flipV","Flip vertical"),"aria-label":j("imageEditor.flipV","Flip vertical"),children:e.jsx(u.NiceIcon,{name:"shuffle",size:16})})]}),o.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${h==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>f(h==="crop"?null:"crop"),title:j("imageEditor.crop","Crop"),"aria-label":j("imageEditor.crop","Crop"),children:e.jsx(u.NiceIcon,{name:"box",size:16})}),h==="crop"&&w.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:xe,title:j("imageEditor.applyCrop","Apply crop"),"aria-label":j("imageEditor.applyCrop","Apply crop"),children:e.jsx(u.NiceIcon,{name:"check",size:16})})]}),o.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.brightness","Brightness"),children:[e.jsx(u.NiceIcon,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.brightness,onChange:H=>ne({brightness:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.brightness","Brightness")})]}),o.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.contrast","Contrast"),children:[e.jsx(u.NiceIcon,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.contrast,onChange:H=>ne({contrast:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.contrast","Contrast")})]}),o.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.saturate","Saturation"),children:[e.jsx(u.NiceIcon,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:w.saturate,onChange:H=>ne({saturate:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("imageEditor.saturate","Saturation")})]}),o.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:j("imageEditor.blur","Blur"),children:[e.jsx(u.NiceIcon,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:w.blur,onChange:H=>ne({blur:Number(H.target.value)}),className:"nice-image-editor__slider",title:j("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 ${h==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>f(h==="annotate"?null:"annotate"),title:j("imageEditor.annotate","Annotate"),"aria-label":j("imageEditor.annotate","Annotate"),children:e.jsx(u.NiceIcon,{name:"edit",size:16})}),h==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:s,onChange:H=>E(H.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:L,onChange:H=>l(H.target.value),className:"nice-image-editor__color",title:j("imageEditor.color","Color")}),w.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ne({annotations:w.annotations.slice(0,-1)}),title:j("imageEditor.removeLastAnnotation","Remove last"),"aria-label":j("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(u.NiceIcon,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:Q,title:j("imageEditor.reset","Reset"),"aria-label":j("imageEditor.reset","Reset"),children:e.jsx(u.NiceIcon,{name:"refresh",size:16})}),v&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:re,children:j("imageEditor.save","Save")}),D&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:D,children:j("imageEditor.cancel","Cancel")})]}):void 0,F=g?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(H=>Math.max(.1,H-.1)),title:"Zoom out","aria-label":"Zoom out",children:e.jsx(u.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(M*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>y(H=>Math.min(5,H+.1)),title:"Zoom in","aria-label":"Zoom in",children:e.jsx(u.NiceIcon,{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 · ",w.rotation,"°"]})]}):void 0;return e.jsx(en.NiceAppShell,{ref:ae,flush:!0,id:R,className:`nice-image-editor nice-image-editor--${i} nice-editor--${a} ${_??""}`,style:{...J,width:q,height:G},toolbar:de,statusBar:F,children:e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":j("imageEditor.label","Image Editor"),...ee,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(P,Bi)})}),e.jsx("canvas",{ref:I,className:"nice-image-editor__canvas",onMouseDown:_e,onMouseMove:he,onMouseUp:ye,style:{cursor:h==="crop"||h==="annotate"?"crosshair":"default",transform:`scale(${M})`,transformOrigin:"center center"}})]})})});En.displayName="NiceImageEditor";const Oi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Fi(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 Ki=0;function Ui(){return`ann-${Date.now()}-${Ki++}`}function Yi(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,r=t.y+t.height/2;return`<ellipse cx="${o}" cy="${r}" rx="${t.width/2}" ry="${t.height/2}" ${a} />`}case"arrow":{const o=t,r=Math.atan2(o.endY-o.y,o.endX-o.x),g=12,x=o.endX-g*Math.cos(r-Math.PI/6),v=o.endY-g*Math.sin(r-Math.PI/6),D=o.endX-g*Math.cos(r+Math.PI/6),N=o.endY-g*Math.sin(r+Math.PI/6);return`<line x1="${o.x}" y1="${o.y}" x2="${o.endX}" y2="${o.endY}" ${a} />
300
+ <polygon points="${o.endX},${o.endY} ${x},${v} ${D},${N}" 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}">${Xi(o.text)}</text>`}case"freehand":{const o=t;return o.points.length<2?"":`<path d="${o.points.map((g,x)=>`${x===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${a} fill="none" />`}case"blur":{const o=t,r=`blur-${o.id}`;return`<defs><filter id="${r}"><feGaussianBlur stdDeviation="${o.intensity??5}" /></filter></defs>
301
+ <rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" fill="transparent" stroke="none" filter="url(#${r})" />`}default:return""}}function Xi(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const In=n.forwardRef(({src:t,alt:i="Annotatable image",annotations:a,activeTool:o,defaultStyle:r,onAnnotationsChange:g,className:x,readOnly:v=!1,minZoom:D=.1,maxZoom:N=5},q)=>{const G=n.useRef(null),P=n.useRef(null),_=n.useRef(null),[J,ie]=n.useState(!1),[ee,ae]=n.useState({width:0,height:0}),[R,j]=n.useReducer(Fi,{annotations:a??[],selectedId:null,activeTool:o??"select",style:{...Oi,...r},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{o&&j({type:"SET_TOOL",tool:o})},[o]),n.useEffect(()=>{g?.(R.annotations)},[R.annotations,g]),n.useEffect(()=>{const y=new Image;y.crossOrigin="anonymous",y.onload=()=>{_.current=y,ae({width:y.naturalWidth,height:y.naturalHeight}),ie(!0)},y.src=t},[t]);const I=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),p=n.useCallback((y,s)=>{const E=G.current;if(!E)return{x:0,y:0};const L=E.getBoundingClientRect();return{x:(y-L.left-R.panX)/R.zoom,y:(s-L.top-R.panY)/R.zoom}},[R.zoom,R.panX,R.panY]),w=n.useCallback(()=>{const y=G.current,s=y?.getContext("2d"),E=_.current;if(!y||!s||!E||!J)return;y.width=P.current?.clientWidth??E.naturalWidth,y.height=P.current?.clientHeight??E.naturalHeight,s.clearRect(0,0,y.width,y.height),s.save(),s.translate(R.panX,R.panY),s.scale(R.zoom,R.zoom),s.drawImage(E,0,0);for(const l of R.annotations){switch(s.save(),s.globalAlpha=l.style.opacity,s.strokeStyle=l.style.strokeColor,s.fillStyle=l.style.fillColor,s.lineWidth=l.style.strokeWidth,l.tool){case"rectangle":s.strokeRect(l.x,l.y,l.width,l.height),l.style.fillColor!=="transparent"&&s.fillRect(l.x,l.y,l.width,l.height);break;case"ellipse":{s.beginPath(),s.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),s.stroke(),l.style.fillColor!=="transparent"&&s.fill();break}case"arrow":{const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();const d=Math.atan2(c.endY-c.y,c.endX-c.x),b=12;s.beginPath(),s.moveTo(c.endX,c.endY),s.lineTo(c.endX-b*Math.cos(d-Math.PI/6),c.endY-b*Math.sin(d-Math.PI/6)),s.lineTo(c.endX-b*Math.cos(d+Math.PI/6),c.endY-b*Math.sin(d+Math.PI/6)),s.closePath(),s.fillStyle=l.style.strokeColor,s.fill();break}case"line":{const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke();break}case"text":{const c=l;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=l;if(c.points.length<2)break;s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let d=1;d<c.points.length;d++)s.lineTo(c.points[d].x,c.points[d].y);s.stroke();break}case"blur":{const c=l;s.filter=`blur(${c.intensity??5}px)`,s.drawImage(E,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),s.filter="none";break}}l.id===R.selectedId&&(s.strokeStyle="#4488ff",s.lineWidth=1,s.setLineDash([4,4]),s.strokeRect(l.x-2,l.y-2,l.width+4,l.height+4),s.setLineDash([])),s.restore()}const L=I.current;if(L.isDrawing&&L.currentAnnotation){s.save();const l=L.currentAnnotation;if(s.globalAlpha=l.style.opacity,s.strokeStyle=l.style.strokeColor,s.lineWidth=l.style.strokeWidth,s.setLineDash([6,3]),l.tool==="freehand"){const c=l;if(c.points.length>=2){s.beginPath(),s.moveTo(c.points[0].x,c.points[0].y);for(let d=1;d<c.points.length;d++)s.lineTo(c.points[d].x,c.points[d].y);s.stroke()}}else if(l.tool==="rectangle")s.strokeRect(l.x,l.y,l.width,l.height);else if(l.tool==="ellipse")s.beginPath(),s.ellipse(l.x+l.width/2,l.y+l.height/2,Math.abs(l.width/2),Math.abs(l.height/2),0,0,Math.PI*2),s.stroke();else if(l.tool==="arrow"||l.tool==="line"){const c=l;s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(c.endX,c.endY),s.stroke()}s.restore()}s.restore()},[R,J]);n.useEffect(()=>{w()},[w]);const X=n.useCallback(y=>{if(v)return;const s=p(y.clientX,y.clientY),E=R.activeTool;if(E==="select"){const c=[...R.annotations].reverse().find(d=>d.tool==="freehand"?!1:s.x>=d.x&&s.x<=d.x+d.width&&s.y>=d.y&&s.y<=d.y+d.height);j({type:"SELECT",id:c?.id??null});return}const L=I.current;L.isDrawing=!0,L.startX=s.x,L.startY=s.y;const l={id:Ui(),style:{...R.style},x:s.x,y:s.y,width:0,height:0};switch(E){case"rectangle":L.currentAnnotation={...l,tool:"rectangle"};break;case"ellipse":L.currentAnnotation={...l,tool:"ellipse"};break;case"arrow":L.currentAnnotation={...l,tool:"arrow",endX:s.x,endY:s.y};break;case"line":L.currentAnnotation={...l,tool:"line",endX:s.x,endY:s.y};break;case"text":L.currentAnnotation={...l,tool:"text",text:"Text",width:100,height:R.style.fontSize??16};break;case"freehand":L.freehandPoints=[s],L.currentAnnotation={...l,tool:"freehand",points:[s]};break;case"blur":L.currentAnnotation={...l,tool:"blur",intensity:5};break}},[v,p,R.activeTool,R.style,R.annotations]),h=n.useCallback(y=>{const s=I.current;if(!s.isDrawing||!s.currentAnnotation)return;const E=p(y.clientX,y.clientY),L=s.currentAnnotation;if(L.tool==="freehand"){s.freehandPoints.push(E),L.points=[...s.freehandPoints];const l=s.freehandPoints.map(d=>d.x),c=s.freehandPoints.map(d=>d.y);L.x=Math.min(...l),L.y=Math.min(...c),L.width=Math.max(...l)-L.x,L.height=Math.max(...c)-L.y}else if(L.tool==="arrow"||L.tool==="line")L.endX=E.x,L.endY=E.y,L.width=Math.abs(E.x-s.startX),L.height=Math.abs(E.y-s.startY);else{const l=Math.min(s.startX,E.x),c=Math.min(s.startY,E.y);L.x=l,L.y=c,L.width=Math.abs(E.x-s.startX),L.height=Math.abs(E.y-s.startY)}w()},[p,w]),f=n.useCallback(()=>{const y=I.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)&&j({type:"ADD_ANNOTATION",annotation:s}),y.isDrawing=!1,y.currentAnnotation=null,y.freehandPoints=[]},[]),B=n.useCallback(y=>{y.preventDefault();const s=y.deltaY>0?.9:1.1,E=Math.max(D,Math.min(N,R.zoom*s));j({type:"SET_ZOOM",zoom:E})},[R.zoom,D,N]);n.useEffect(()=>{if(v)return;const y=s=>{(s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey?(s.preventDefault(),j({type:"UNDO"})):(s.metaKey||s.ctrlKey)&&(s.key==="y"||s.key==="z"&&s.shiftKey)?(s.preventDefault(),j({type:"REDO"})):(s.key==="Delete"||s.key==="Backspace")&&R.selectedId&&j({type:"DELETE_ANNOTATION",id:R.selectedId})};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[v,R.selectedId]),n.useImperativeHandle(q,()=>({exportAsDataURL:async(y="png",s=.92)=>{const E=document.createElement("canvas"),L=_.current;if(!L)return"";E.width=L.naturalWidth,E.height=L.naturalHeight;const l=E.getContext("2d");l.drawImage(L,0,0);for(const c of R.annotations){if(l.save(),l.globalAlpha=c.style.opacity,l.strokeStyle=c.style.strokeColor,l.fillStyle=c.style.fillColor,l.lineWidth=c.style.strokeWidth,c.tool==="rectangle")l.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")l.beginPath(),l.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),l.stroke();else if(c.tool==="freehand"){const d=c;if(d.points.length>=2){l.beginPath(),l.moveTo(d.points[0].x,d.points[0].y);for(let b=1;b<d.points.length;b++)l.lineTo(d.points[b].x,d.points[b].y);l.stroke()}}else if(c.tool==="text"){const d=c;l.font=`${d.style.fontSize??16}px ${d.style.fontFamily??"sans-serif"}`,l.fillStyle=d.style.strokeColor,l.fillText(d.text,d.x,d.y+(d.style.fontSize??16))}l.restore()}return E.toDataURL(`image/${y}`,s)},exportAnnotations:()=>[...R.annotations],importAnnotations:y=>{j({type:"SET_ANNOTATIONS",annotations:y})},exportAsSVG:()=>{const{width:y,height:s}=ee,E=R.annotations.map(Yi);return`<svg xmlns="http://www.w3.org/2000/svg" width="${y}" height="${s}" viewBox="0 0 ${y} ${s}">
302
+ ${E.join(`
303
+ `)}
304
+ </svg>`},undo:()=>j({type:"UNDO"}),redo:()=>j({type:"REDO"}),setZoom:y=>{j({type:"SET_ZOOM",zoom:Math.max(D,Math.min(N,y))})},fitToScreen:()=>{const y=P.current,s=_.current;if(!y||!s)return;const E=y.clientWidth/s.naturalWidth,L=y.clientHeight/s.naturalHeight,l=Math.min(E,L,1);j({type:"SET_ZOOM",zoom:l}),j({type:"SET_PAN",panX:0,panY:0})},clear:()=>j({type:"CLEAR"})}),[R.annotations,ee,D,N]);const te=n.useCallback(y=>{if(y.touches.length!==1)return;const s=y.touches[0];X({clientX:s.clientX,clientY:s.clientY,preventDefault:()=>{}})},[X]),M=n.useCallback(y=>{if(y.touches.length!==1)return;const s=y.touches[0];h({clientX:s.clientX,clientY:s.clientY})},[h]);return e.jsx("div",{ref:P,className:`nice-image-annotator ${x??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:G,className:"nice-image-annotator__canvas",style:{cursor:R.activeTool==="select"?"default":"crosshair"},onMouseDown:X,onMouseMove:h,onMouseUp:f,onMouseLeave:f,onWheel:B,onTouchStart:te,onTouchMove:M,onTouchEnd:f,role:"img","aria-label":i})})});In.displayName="NiceImageAnnotator";const qi=[{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"}],Mn=[{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}],Tn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:a=0,initialZoom:o=1,aspectRatios:r=Mn,defaultAspectRatio:g="free",customAspectRatio:x,showRotation:v=!0,showFlip:D=!0,showZoom:N=!0,minZoom:q=.5,maxZoom:G=3,zoomStep:P=.1,showGrid:_=!0,overlayColor:J="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:ie="bottom",toolbarCollapsible:ee=!1,defaultToolbarCollapsed:ae=!1,onChange:R,tutorial:j,className:I="",style:p,"data-testid":w="nice-crop-editor"})=>{const{t:X}=u.useNiceTranslation(),h=n.useRef(null),f=n.useRef(null),[B,te]=n.useState(i),[M,y]=n.useState(a),[s,E]=n.useState(o),[L,l]=n.useState(!1),[c,d]=n.useState(!1),[b,z]=n.useState(g),[$,C]=n.useState(ae),[S,T]=n.useState(!1),[k,A]=n.useState({x:0,y:0,crop:B}),O=b==="custom"?x:r.find(F=>F.value===b)?.ratio;n.useEffect(()=>{R?.({crop:B,rotation:M,flipH:L,flipV:c,zoom:s})},[B,M,L,c,s,R]);const ce=n.useCallback((F,H)=>{if(!O)return F;const U=h.current?.clientWidth??400,ge=h.current?.clientHeight??300,le=F.width/100*U,K=F.height/100*ge,Z=le/K;if(Math.abs(Z-O)<.01)return F;if(H?.includes("e")||H?.includes("w")){const oe=le/O/ge*100;return{...F,height:Math.min(100-F.y,Math.max(5,oe))}}else if(H?.includes("n")||H?.includes("s")){const oe=K*O/U*100;return{...F,width:Math.min(100-F.x,Math.max(5,oe))}}else{const oe=le/O/ge*100;return{...F,height:Math.min(100-F.y,Math.max(5,oe))}}},[O]),pe=n.useCallback((F,H)=>{H===!1||(F.preventDefault(),F.stopPropagation(),T(H),!h.current?.getBoundingClientRect())||A({x:F.clientX,y:F.clientY,crop:{...B}})},[B]),ne=n.useCallback(F=>{if(!S||!h.current)return;const H=h.current.getBoundingClientRect(),U=(F.clientX-k.x)/H.width*100,ge=(F.clientY-k.y)/H.height*100;let le={...k.crop};if(S==="crop")le.x=Math.max(0,Math.min(100-le.width,k.crop.x+U)),le.y=Math.max(0,Math.min(100-le.height,k.crop.y+ge));else{switch(S){case"resize-nw":le.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+U)),le.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ge)),le.width=k.crop.width-(le.x-k.crop.x),le.height=k.crop.height-(le.y-k.crop.y);break;case"resize-ne":le.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ge)),le.width=Math.max(5,Math.min(100-le.x,k.crop.width+U)),le.height=k.crop.height-(le.y-k.crop.y);break;case"resize-sw":le.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+U)),le.width=k.crop.width-(le.x-k.crop.x),le.height=Math.max(5,Math.min(100-le.y,k.crop.height+ge));break;case"resize-se":le.width=Math.max(5,Math.min(100-le.x,k.crop.width+U)),le.height=Math.max(5,Math.min(100-le.y,k.crop.height+ge));break;case"resize-n":le.y=Math.max(0,Math.min(k.crop.y+k.crop.height-5,k.crop.y+ge)),le.height=k.crop.height-(le.y-k.crop.y);break;case"resize-s":le.height=Math.max(5,Math.min(100-le.y,k.crop.height+ge));break;case"resize-e":le.width=Math.max(5,Math.min(100-le.x,k.crop.width+U));break;case"resize-w":le.x=Math.max(0,Math.min(k.crop.x+k.crop.width-5,k.crop.x+U)),le.width=k.crop.width-(le.x-k.crop.x);break}le=ce(le,S.replace("resize-",""))}te(le)},[S,k,ce]),je=n.useCallback(()=>{T(!1)},[]);n.useEffect(()=>{if(S)return document.addEventListener("mousemove",ne),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",je)}},[S,ne,je]);const ve=n.useCallback(()=>{y(F=>(F-90+360)%360)},[]),_e=n.useCallback(()=>{y(F=>(F+90)%360)},[]),he=n.useCallback(()=>{l(F=>!F)},[]),ye=n.useCallback(()=>{d(F=>!F)},[]),xe=n.useCallback(()=>{te(i),y(a),E(o),l(!1),d(!1),z(g)},[i,a,o,g]);n.useEffect(()=>{te(F=>ce(F))},[b,ce]);const re=`translate(-50%, -50%) scale(${s}) rotate(${M}deg) scaleX(${L?-1:1}) scaleY(${c?-1:1})`,Q=ie==="top"?"column-reverse":ie==="left"?"row-reverse":ie==="right"?"row":"column",de=ie==="left"||ie==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${ie} ${I}`,style:{position:"relative",display:"flex",flexDirection:Q,gap:12,...p},"data-testid":w,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(j,qi)})}),e.jsxs("div",{ref:h,className:"nice-crop-editor__container","data-testid":`${w}-container`,children:[e.jsx("img",{ref:f,src:t||void 0,alt:"",className:"nice-crop-editor__image",style:{transform:re},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:J},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${B.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-B.y-B.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${B.y}%`,left:0,width:`${B.x}%`,height:`${B.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${B.y}%`,right:0,width:`${100-B.x-B.width}%`,height:`${B.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${B.x}%`,top:`${B.y}%`,width:`${B.width}%`,height:`${B.height}%`},onMouseDown:F=>pe(F,"crop"),"data-testid":`${w}-crop-area`,children:[_&&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:F=>pe(F,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:F=>pe(F,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:F=>pe(F,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:F=>pe(F,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:F=>pe(F,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:F=>pe(F,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:F=>pe(F,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:F=>pe(F,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${$?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:de?"column":"row",flexWrap:de?"nowrap":"wrap",gap:8,alignItems:de?"stretch":"center",flexShrink:0},children:[ee&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!$,"aria-label":$?"Show toolbar":"Hide toolbar",onClick:()=>C(F=>!F),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(u.NiceIcon,{name:$?"chevron-right":"chevron-down",size:14})}),!$&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:X("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:r.map(F=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${b===F.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>z(F.value),title:F.label,children:F.label},F.value))})]}),N&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[X("zoom","Zoom"),": ",Math.round(s*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:q,max:G,step:P,value:s,onChange:F=>E(parseFloat(F.target.value)),"data-testid":`${w}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ve,title:X("rotateLeft","Rotate Left"),"aria-label":X("rotateLeft","Rotate Left"),children:e.jsx(u.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:_e,title:X("rotateRight","Rotate Right"),"aria-label":X("rotateRight","Rotate Right"),children:e.jsx(u.NiceIcon,{name:"forward",size:16})})]}),D&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${L?"nice-crop-editor__btn--active":""}`,onClick:he,title:X("flipHorizontal","Flip Horizontal"),"aria-label":X("flipHorizontal","Flip Horizontal"),children:e.jsx(u.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${c?"nice-crop-editor__btn--active":""}`,onClick:ye,title:X("flipVertical","Flip Vertical"),"aria-label":X("flipVertical","Flip Vertical"),children:e.jsx(u.NiceIcon,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:xe,title:X("reset","Reset"),"aria-label":X("reset","Reset"),children:e.jsx(u.NiceIcon,{name:"refresh",size:16})})]})]})]})]})};Tn.displayName="NiceCropEditor";const Gi=[{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"}],Vi=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Wi={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},Rn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",id:v,className:D,style:N,accessMode:q,src:G,annotations:P=[],onAnnotationsChange:_,activeTool:J,onToolChange:ie,currentPage:ee=1,onPageChange:ae,totalPages:R=1,defaultColor:j="var(--nice-warning, #ffff00)",tools:I=Vi,author:p,zoom:w=1,onZoomChange:X,onAnnotationClick:h,onAnnotationDelete:f,tutorial:B},te)=>{const M=u.useNiceAccessMode(q,v),y=M==="hidden";M==="disabled"&&(r=!0),M==="readOnly"&&(g=!0);const{t:s}=u.useNiceTranslation(),E=u.useControlId(v),L=P.filter(S=>S.page===ee),l=n.useCallback(S=>{ie?.(J===S?null:S)},[J,ie]),c=n.useCallback(S=>{if(g||!J||J==="freehand")return;const T=S.currentTarget.getBoundingClientRect(),k=(S.clientX-T.left)/T.width,A=(S.clientY-T.top)/T.height,O={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:J,page:ee,x:k,y:A,color:j,author:p,createdAt:new Date().toISOString(),text:J==="text"?"":void 0};_?.([...P,O])},[g,J,ee,j,p,P,_]);if(y)return null;const d=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,o&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,b=g?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[I.map(S=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${J===S?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>l(S),disabled:r,title:s(`pdfTool_${S}`,S),children:e.jsx(u.NiceIcon,{name:Wi[S],size:16})},S)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:r,onClick:()=>X?.(Math.max(.25,w-.25)),title:s("zoomOut","Zoom out"),"aria-label":s("zoomOut","Zoom out"),children:e.jsx(u.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(w*100),"%"]}),e.jsx("button",{type:"button",disabled:r,onClick:()=>X?.(Math.min(4,w+.25)),title:s("zoomIn","Zoom in"),"aria-label":s("zoomIn","Zoom in"),children:e.jsx(u.NiceIcon,{name:"plus",size:16})})]}),z=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:r||ee<=1,onClick:()=>ae?.(ee-1),"aria-label":s("prevPage","Previous page"),children:e.jsx(u.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("span",{children:s("pageOf","{page} / {total}").replace("{page}",String(ee)).replace("{total}",String(R))}),e.jsx("button",{type:"button",disabled:r||ee>=R,onClick:()=>ae?.(ee+1),"aria-label":s("nextPage","Next page"),children:e.jsx(u.NiceIcon,{name:"chevron-right",size:16})})]}),C=!!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(en.NiceAppShell,{ref:te,flush:!0,id:E,className:`nice-pdf-annotation nice-size-${x}${D?` ${D}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:N,menubar:d,toolbar:b,bottomPanel:z,statusBar:C,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(u.NiceTutorialButton,{steps:u.resolveTutorial(B,Gi)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${w})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:G||void 0,className:"nice-pdf-annotation__frame",title:s("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:c,children:L.map(S=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${S.tool}`,style:{left:`${S.x*100}%`,top:`${S.y*100}%`,backgroundColor:S.color},onClick:T=>{T.stopPropagation(),h?.(S)},title:S.text??S.tool,children:[S.text&&e.jsx("span",{children:S.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:T=>{T.stopPropagation(),f?.(S.id)},"aria-label":s("delete","Delete"),children:e.jsx(u.NiceIcon,{name:"close",size:14})})]},S.id))})]})]})})});Rn.displayName="NicePDFAnnotationEditor";function Gt(t,i){const a=i.getBoundingClientRect();let o,r,g;if("touches"in t){const x=t.touches[0];o=x.clientX-a.left,r=x.clientY-a.top,g=x.force}else"pressure"in t?(o=t.clientX-a.left,r=t.clientY-a.top,g=t.pressure):(o=t.clientX-a.left,r=t.clientY-a.top);return{x:o,y:r,time:Date.now(),pressure:g!==void 0?g:.5}}function Vt(t,i,a,o,r){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),x=Math.min(g/5,1),v=o-x*(o-a),D=t.pressure??.5,N=a+D*(o-a);return v*.7+N*.3}function Wt(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 Ji=n.forwardRef(function(i,a){const{value:o,onChange:r,onChangeDataUrl:g,label:x,width:v="100%",height:D=200,penColor:N="",penWidth:q=2,minWidth:G=.5,maxWidth:P=4,backgroundColor:_="",placeholder:J,showClearButton:ie=!0,showUndoButton:ee=!0,showColorPicker:ae=!1,showSizeSlider:R=!1,velocityFilterWeight:j=.7,throttle:I=16,disabled:p=!1,readOnly:w=!1,displayMode:X=!1,onBegin:h,onEnd:f,className:B,"data-testid":te}=i,{t:M}=u.useNiceTranslation(),y=J||M("signature.placeholder","Sign here"),s=w||X,E=X?!1:ie,L=X?!1:ee,l=X?!1:ae,c=X?!1:R,d=n.useRef(null),[b,z]=n.useState(o?.strokes??[]),[$,C]=n.useState([]),[S,T]=n.useState(!1),[k,A]=n.useState(N),[O,ce]=n.useState(q),pe=n.useRef(null),ne=n.useRef(0),je=u.useThemeIsDark(d),ve=_||(je?"#0f172a":"#ffffff"),_e=N||(je?"#f8fafc":"#111827"),he=k||_e,ye=b.length===0&&$.length===0;n.useEffect(()=>{const Z=d.current;if(!Z)return;const Y=Z.getContext("2d");if(!Y)return;const oe=Z.getBoundingClientRect(),me=window.devicePixelRatio||1;Z.width=oe.width*me,Z.height=oe.height*me,Y.scale(me,me),xe()},[v,D]);const xe=n.useCallback(()=>{const Z=d.current;if(!Z)return;const Y=Z.getContext("2d");if(!Y)return;const oe=Z.getBoundingClientRect();Y.fillStyle=ve,Y.fillRect(0,0,oe.width,oe.height),b.forEach(me=>{if(Y.strokeStyle=me.color||_e,!(me.points.length<2))for(let be=1;be<me.points.length;be++){const we=me.points[be-1],Me=me.points[be],Te=Vt(Me,we,G,P);Wt(Y,we,Me,Te)}})},[b,ve,_e,G,P,j]);n.useEffect(()=>{xe()},[xe]),n.useEffect(()=>{o?.strokes&&z(o.strokes)},[o]),n.useEffect(()=>{const Z=d.current;if(Z)if(b.length===0)r?.(null),g?.(null);else{const Y=Z.getBoundingClientRect();r?.({strokes:b,width:Y.width,height:Y.height,timestamp:Date.now()}),g?.(Z.toDataURL("image/png"))}},[b,r,g]);const re=n.useCallback(Z=>{if(p||s)return;const Y=d.current;if(!Y)return;Y.setPointerCapture(Z.pointerId);const oe=Gt(Z.nativeEvent,Y);T(!0),C([oe]),pe.current=oe,ne.current=oe.time,h?.()},[p,s,h]),Q=n.useCallback(Z=>{if(!S||p||s)return;const Y=d.current;if(!Y)return;const oe=Y.getContext("2d");if(!oe)return;const me=Date.now();if(me-ne.current<I)return;const be=Gt(Z.nativeEvent,Y),we=pe.current;if(we){oe.strokeStyle=he;const Me=Vt(be,we,G,P);Wt(oe,we,be,Me)}C(Me=>[...Me,be]),pe.current=be,ne.current=me},[S,p,s,he,G,P,j,I]),de=n.useCallback(Z=>{if(!S)return;const Y=d.current;if(Y&&Y.releasePointerCapture(Z.pointerId),$.length>0){const oe={points:$,color:he,width:O};z(me=>[...me,oe])}T(!1),C([]),pe.current=null,f?.()},[S,$,he,O,f]),F=n.useCallback(()=>{z([]),C([]),xe()},[xe]),H=n.useCallback(()=>{z(Z=>Z.slice(0,-1))},[]),U=n.useCallback((Z="png",Y=.92)=>{const oe=d.current;if(!oe)return"";const me=Z==="jpeg"?"image/jpeg":"image/png";return oe.toDataURL(me,Y)},[]),ge=n.useCallback(async(Z="png",Y=.92)=>{const oe=d.current;return oe?new Promise(me=>{const be=Z==="jpeg"?"image/jpeg":"image/png";oe.toBlob(we=>me(we),be,Y)}):null},[]),le=n.useCallback(()=>{const Z=d.current;if(!Z)return"";const Y=Z.getBoundingClientRect(),oe=b.map(me=>me.points.length<2?"":`<path d="${me.points.reduce((we,Me,Te)=>Te===0?`M ${Me.x} ${Me.y}`:`${we} L ${Me.x} ${Me.y}`,"")}" stroke="${me.color||_e}" stroke-width="${me.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
305
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${Y.width}" height="${Y.height}" viewBox="0 0 ${Z.width} ${Z.height}">
306
+ <rect width="100%" height="100%" fill="${ve}"/>
307
+ ${oe}
308
+ </svg>`},[b,ve,_e]);n.useImperativeHandle(a,()=>({clear:F,undo:H,isEmpty:()=>b.length===0,getData:()=>{const Z=d.current;if(!Z||b.length===0)return null;const Y=Z.getBoundingClientRect();return{strokes:b,width:Y.width,height:Y.height,timestamp:Date.now()}},setData:Z=>{z(Z.strokes)},toDataURL:U,toBlob:ge,toSVG:le,getCanvas:()=>d.current}),[b,F,H,U,ge,le]),n.useEffect(()=>{const Z=d.current;if(!Z)return;const Y=oe=>{S&&oe.preventDefault()};return Z.addEventListener("touchmove",Y,{passive:!1}),()=>Z.removeEventListener("touchmove",Y)},[S]);const K=E||L||l||c;return e.jsxs("div",{className:`nice-signature ${p?"nice-signature--disabled":""} ${s?"nice-signature--readonly":""} ${B??""}`,style:{width:v},"data-testid":te,children:[x&&e.jsx("label",{className:"nice-signature__label",children:x}),K&&e.jsxs("div",{className:"nice-signature__toolbar",children:[l&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:k,onChange:Z=>A(Z.target.value),disabled:p||s,title:"Pen color"})}),c&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:G,max:P,step:.5,value:O,onChange:Z=>ce(parseFloat(Z.target.value)),disabled:p||s,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[L&&e.jsx("button",{type:"button",onClick:H,disabled:p||s||b.length===0,className:"nice-signature__btn",title:"Undo","aria-label":"Undo",children:e.jsx(u.NiceIcon,{name:"reply",size:16})}),E&&e.jsx("button",{type:"button",onClick:F,disabled:p||s||ye,className:"nice-signature__btn",title:"Clear","aria-label":"Clear",children:e.jsx(u.NiceIcon,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:D},children:[e.jsx("canvas",{ref:d,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:p||s?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:re,onPointerMove:Q,onPointerUp:de,onPointerLeave:de}),ye&&!S&&y&&e.jsx("div",{className:"nice-signature__placeholder",children:y}),e.jsx("div",{className:"nice-signature__line"})]})]})}),Jt="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Jt)){const t=document.createElement("style");t.id=Jt,t.textContent=`
309
+ .nice-signature {
310
+ display: flex;
311
+ flex-direction: column;
312
+ border: 1px solid var(--nice-border, #e0e0e0);
313
+ border-radius: var(--nice-radius-sm, 4px);
314
+ overflow: hidden;
315
+ background: var(--nice-bg-surface, #fff);
316
+ }
317
+
318
+ .nice-signature--disabled {
319
+ opacity: 0.6;
320
+ }
321
+
322
+ .nice-signature__toolbar {
323
+ display: flex;
324
+ align-items: center;
325
+ gap: var(--nice-space-2, 8px);
326
+ padding: var(--nice-space-2, 8px);
327
+ background: var(--nice-bg-tertiary, #f5f5f5);
328
+ border-bottom: 1px solid var(--nice-border, #e0e0e0);
329
+ }
330
+
331
+ .nice-signature__color-picker input {
332
+ width: 32px;
333
+ height: 32px;
334
+ padding: var(--nice-space-0-5, 2px);
335
+ border: 1px solid var(--nice-border, #e0e0e0);
336
+ border-radius: var(--nice-radius-sm, 4px);
337
+ cursor: pointer;
338
+ }
339
+
340
+ .nice-signature__size-slider {
341
+ flex: 1;
342
+ max-width: 120px;
343
+ }
344
+
345
+ .nice-signature__size-slider input {
346
+ width: 100%;
347
+ }
348
+
349
+ .nice-signature__actions {
350
+ display: flex;
351
+ gap: var(--nice-space-1, 4px);
352
+ margin-left: auto;
353
+ }
354
+
355
+ .nice-signature__btn {
356
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
357
+ border: 1px solid var(--nice-border, #e0e0e0);
358
+ border-radius: var(--nice-radius-sm, 4px);
359
+ background: var(--nice-bg-surface, #fff);
360
+ cursor: pointer;
361
+ font-size: 14px;
362
+ }
363
+
364
+ .nice-signature__btn:hover:not(:disabled) {
365
+ background: var(--nice-bg-hover, #f0f0f0);
366
+ }
367
+
368
+ .nice-signature__btn:disabled {
369
+ opacity: 0.4;
370
+ cursor: not-allowed;
371
+ }
372
+
373
+ .nice-signature__canvas-wrapper {
374
+ position: relative;
375
+ background: var(--nice-bg, #FFF);
376
+ }
377
+
378
+ .nice-signature__canvas {
379
+ display: block;
380
+ }
381
+
382
+ .nice-signature__placeholder {
383
+ position: absolute;
384
+ top: 50%;
385
+ left: 50%;
386
+ transform: translate(-50%, -50%);
387
+ color: var(--nice-text-secondary, #999);
388
+ font-size: 14px;
389
+ pointer-events: none;
390
+ user-select: none;
391
+ }
392
+
393
+ .nice-signature__line {
394
+ position: absolute;
395
+ /* Sit in the lower third (a natural signature baseline) rather than pinned to
396
+ the very bottom. */
397
+ bottom: 64px;
398
+ left: 20px;
399
+ right: 20px;
400
+ height: 1px;
401
+ background: var(--nice-border, #ccc);
402
+ pointer-events: none;
403
+ }
404
+
405
+ /* Display component */
406
+ .nice-signature-display {
407
+ border: 1px solid var(--nice-border, #e0e0e0);
408
+ border-radius: var(--nice-radius-sm, 4px);
409
+ overflow: hidden;
410
+ }
411
+
412
+ .nice-signature-display__canvas-wrapper {
413
+ position: relative;
414
+ background: var(--nice-bg, #FFF);
415
+ }
416
+
417
+ .nice-signature-display__canvas {
418
+ display: block;
419
+ }
420
+
421
+ .nice-signature-display__placeholder {
422
+ position: absolute;
423
+ top: 50%;
424
+ left: 50%;
425
+ transform: translate(-50%, -50%);
426
+ color: var(--nice-text-secondary, #999);
427
+ font-size: 14px;
428
+ }
429
+ `,document.head.appendChild(t)}const An=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",id:v,className:D,style:N,accessMode:q,mode:G="manual",onScan:P,onModeChange:_,beepOnScan:J=!0,beepFrequency:ie=1800,beepDuration:ee=150,placeholder:ae,scanHistory:R=[],showHistory:j=!0,maxHistory:I=10,autoFocus:p=!0,onCameraFrame:w},X)=>{const h=u.useNiceAccessMode(q,v),f=h==="hidden";h==="disabled"&&(r=!0),h==="readOnly"&&(g=!0);const{t:B}=u.useNiceTranslation(),te=u.useControlId(v),[M,y]=n.useState(""),s=n.useRef(null),E=n.useRef(null),L=n.useCallback(()=>{if(J)try{E.current||(E.current=new AudioContext);const d=E.current,b=d.createOscillator(),z=d.createGain();b.connect(z),z.connect(d.destination),b.frequency.value=ie,b.type="square",z.gain.value=.3,b.start(),b.stop(d.currentTime+ee/1e3)}catch{}},[J,ie,ee]),l=n.useCallback(()=>{M.trim()&&(L(),P?.({value:M.trim(),format:"manual",scannedAt:new Date}),y(""),s.current?.focus())},[M,P,L]),c=R.slice(0,I);return f?null:e.jsxs("div",{ref:X,id:te,className:`nice-scanner nice-size-${x}${D?` ${D}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:N,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${G==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>_?.("camera"),disabled:r,children:[e.jsx(u.NiceIcon,{name:"camera",size:16})," ",B("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${G==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>_?.("manual"),disabled:r,children:[e.jsx(u.NiceIcon,{name:"edit",size:16})," ",B("manual","Manual")]})]}),G==="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(u.NiceIcon,{name:"camera",size:32})}),e.jsx("p",{children:B("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),G==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:s,className:"nice-input nice-scanner__input",type:"text",value:M,onChange:d=>y(d.target.value),onKeyDown:d=>d.key==="Enter"&&l(),placeholder:ae??B("enterCode","Enter or scan code…"),disabled:r,autoFocus:p}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:l,disabled:r||!M.trim(),"aria-label":B("submit","Submit"),children:e.jsx(u.NiceIcon,{name:"check",size:16})})]}),j&&c.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:B("recentScans","Recent scans")}),c.map((d,b)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:d.value}),d.format&&e.jsx("span",{className:"nice-scanner__history-format",children:d.format}),e.jsx("span",{className:"nice-scanner__history-time",children:d.scannedAt.toLocaleTimeString()})]},b))]}),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="NiceScannerControl";const Zi=[{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 Qi=1;function ea(t){return{id:`new-${Qi++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"pcs"}}function Dn(t){const a=t.quantity*t.unitPrice*(1-(t.discount??0)/100),o=Math.round(a*100)/100,r=Math.round(o*(t.vatRate??0)/100*100)/100;return{...t,netAmount:o,grossAmount:o+r}}function ta(t){const i=t.map(Dn),a=i.reduce((v,D)=>v+(D.netAmount??0),0),o=i.reduce((v,D)=>v+(D.grossAmount??0),0),r=o-a,g=new Map;for(const v of i){const D=v.vatRate??0,N=g.get(D)??{base:0,amount:0};N.base+=v.netAmount??0,N.amount+=(v.grossAmount??0)-(v.netAmount??0),g.set(D,N)}const x=Array.from(g.entries()).map(([v,D])=>({rate:v,base:Math.round(D.base*100)/100,amount:Math.round(D.amount*100)/100}));return{totalNet:Math.round(a*100)/100,totalVat:Math.round(r*100)/100,totalGross:Math.round(o*100)/100,vatBreakdown:x}}const na={pl:"PLN",cs:"CZK",sk:"EUR",hu:"HUF",ro:"RON",bg:"BGN",uk:"UAH",de:"EUR",fr:"EUR",es:"EUR",it:"EUR",nl:"EUR",pt:"EUR",fi:"EUR",sv:"SEK",no:"NOK",da:"DKK",ja:"JPY",zh:"CNY",ko:"KRW",hi:"INR",th:"THB",vi:"VND",id:"IDR",ms:"MYR",fil:"PHP",bn:"BDT",ar:"AED",sw:"KES"};function ia(t){const i=na[t];if(!i)return"$";try{return new Intl.NumberFormat(t,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(0).find(o=>o.type==="currency")?.value??"$"}catch{return"$"}}const aa=["pcs","h","kg","m","svc"],zn=n.forwardRef(({label:t,helperText:i,error:a,required:o,disabled:r,readOnly:g,size:x="md",name:v,id:D,className:N,style:q,accessMode:G,value:P=[],onChange:_,onTotalsChange:J,currencySymbol:ie,defaultVatRate:ee=23,vatRates:ae=[0,5,8,23],units:R,showDiscount:j=!0,showUnit:I=!0,showTotals:p=!0,editable:w=!0,maxLines:X,tutorial:h},f)=>{const B=u.useNiceAccessMode(G,D),te=B==="hidden";B==="disabled"&&(r=!0),B==="readOnly"&&(g=!0);const{t:M,lang:y}=u.useNiceTranslation(),s=u.useControlId(D),E=n.useMemo(()=>ie??ia(y),[ie,y]),L=n.useMemo(()=>R??aa.map(C=>M(`invoice.unit.${C}`,C)),[R,M]),l=n.useMemo(()=>P.map(Dn),[P]),c=n.useMemo(()=>ta(P),[P]);n.useEffect(()=>{J?.(c)},[c,J]);const d=n.useCallback((C,S,T)=>{const k=[...P];k[C]={...k[C],[S]:T},_?.(k)},[P,_]),b=n.useCallback(()=>{X&&P.length>=X||_?.([...P,ea(ee)])},[P,_,ee,X]),z=n.useCallback(C=>{_?.(P.filter((S,T)=>T!==C))},[P,_]),$=C=>`${C.toFixed(2)} ${E}`;return te?null:e.jsxs("div",{ref:f,id:s,className:`nice-invoice-lines nice-size-${x}${N?` ${N}`:""}${a?" nice-error":""}${r?" nice-disabled":""}`,style:{position:"relative",...q},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(u.NiceTutorialButton,{steps:u.resolveTutorial(h,Zi)})}),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:M("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:M("qty","Qty")}),I&&e.jsx("th",{className:"nice-il__th-unit",children:M("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:M("unitPrice","Unit Price")}),j&&e.jsx("th",{className:"nice-il__th-disc",children:M("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:M("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:M("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:M("gross","Gross")}),w&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:l.map((C,S)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:S+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:C.description,onChange:T=>d(S,"description",T.target.value),disabled:r,readOnly:g,placeholder:M("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:C.quantity,onChange:T=>d(S,"quantity",parseFloat(T.target.value)||0),disabled:r,readOnly:g,min:0,step:"any"})}),I&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:C.unit??"",onChange:T=>d(S,"unit",T.target.value),disabled:r,children:L.map(T=>e.jsx("option",{value:T,children:T},T))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:C.unitPrice,onChange:T=>d(S,"unitPrice",parseFloat(T.target.value)||0),disabled:r,readOnly:g,min:0,step:"0.01"})}),j&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:C.discount??0,onChange:T=>d(S,"discount",parseFloat(T.target.value)||0),disabled:r,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:C.vatRate??0,onChange:T=>d(S,"vatRate",parseInt(T.target.value,10)),disabled:r,children:ae.map(T=>e.jsxs("option",{value:T,children:[T,"%"]},T))})}),e.jsx("td",{className:"nice-il__cell-net",children:$(C.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:$(C.grossAmount??0)}),w&&!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:()=>z(S),disabled:r,title:M("remove","Remove"),"aria-label":M("remove","Remove"),children:e.jsx(u.NiceIcon,{name:"close",size:14})})})]},C.id))})]}),w&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:b,disabled:r||X!=null&&P.length>=X,children:["+ ",M("addLine","Add line")]}),p&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[M("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:$(c.totalNet)})]}),c.vatBreakdown.map(C=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",C.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:$(C.amount)})]},C.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[M("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:$(c.totalGross)})]})]}),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="NiceInvoiceLineEditor";const Ln=n.forwardRef(({value:t="",onChange:i,suggestions:a=[],onSearch:o,trigger:r="@",renderSuggestion:g,placeholder:x,rows:v=3,label:D,helperText:N,error:q,required:G,disabled:P,readOnly:_,loading:J,labelPlacement:ie,errorPlacement:ee,labelWidth:ae,controlWidth:R,size:j="md",name:I,id:p,className:w,style:X,...h},f)=>{const B=u.useControlId(p),[te,M]=n.useState(!1),[y,s]=n.useState(""),[E,L]=n.useState(0),[l,c]=n.useState({top:0,left:0}),d=n.useRef(null),b=n.useRef(-1),$=a.map(A=>typeof A=="string"?{key:A,label:A}:A).filter(A=>A.label.toLowerCase().includes(y.toLowerCase())),C=n.useCallback(()=>{M(!1),s(""),L(0),b.current=-1},[]),S=n.useCallback(A=>{const O=d.current;if(!O||b.current<0)return;const ce=t.slice(0,b.current),pe=t.slice(O.selectionStart),ne=`${r}${A.label} `,je=ce+ne+pe;i?.(je),C(),requestAnimationFrame(()=>{const ve=ce.length+ne.length;O.setSelectionRange(ve,ve),O.focus()})},[t,i,r,C]),T=n.useCallback(A=>{const O=A.target.value;i?.(O);const ce=A.target.selectionStart,pe=O.slice(0,ce),ne=pe.lastIndexOf(r);if(ne>=0){const je=ne>0?pe[ne-1]:" ",ve=pe.slice(ne+r.length);if(/\s/.test(je)&&!/\s/.test(ve)){b.current=ne;const _e=ve;s(_e),M(!0),L(0),o?.(_e);const he=A.target,ye=he.getBoundingClientRect(),xe=parseInt(getComputedStyle(he).lineHeight)||20,re=pe.split(`
430
+ `);c({top:ye.top+re.length*xe+4-he.scrollTop,left:ye.left+8});return}}C()},[i,r,o,C]),k=n.useCallback(A=>{!te||$.length===0||(A.key==="ArrowDown"?(A.preventDefault(),L(O=>(O+1)%$.length)):A.key==="ArrowUp"?(A.preventDefault(),L(O=>(O-1+$.length)%$.length)):A.key==="Enter"?(A.preventDefault(),$[E]&&S($[E])):A.key==="Escape"&&C())},[te,$,E,S,C]);return n.useEffect(()=>{if(!te)return;const A=O=>{const ce=d.current;ce&&!ce.contains(O.target)&&C()};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[te,C]),e.jsxs("div",{className:`nice-field nice-field--${j} ${ie==="left"?"nice-field--label-left":""} ${ee==="right"?"nice-field--error-right":""} ${J?"nice-field--loading":""} ${w||""}`,style:{...X,...ae!=null&&{"--nice-field-label-width":typeof ae=="number"?`${ae}px`:ae},...R!=null&&{"--nice-field-control-width":typeof R=="number"?`${R}px`:R}},"aria-busy":J||void 0,...h,children:[D&&e.jsx("label",{htmlFor:B,className:`nice-field__label ${G?"nice-field__label--required":""}`,children:D}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:`nice-mention nice-mention--${j} ${q?"nice-mention--error":""} ${P?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:A=>{d.current=A,typeof f=="function"?f(A):f&&(f.current=A)},id:B,name:I,className:"nice-mention__input",value:t,onChange:T,onKeyDown:k,placeholder:x,rows:v,disabled:P,readOnly:_,"aria-invalid":!!q,"aria-describedby":q?`${B}-error`:N?`${B}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":te}),te&&$.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:l.top,left:l.left},children:$.map((A,O)=>e.jsx("li",{role:"option","aria-selected":O===E,className:`nice-mention__suggestion ${O===E?"nice-mention__suggestion--active":""}`,onMouseDown:ce=>{ce.preventDefault(),S(A)},onMouseEnter:()=>L(O),children:g?g(A):e.jsxs(e.Fragment,{children:[A.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:A.icon}),e.jsx("span",{children:A.label})]})},A.key))})]}),J&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ee==="right"&&q&&e.jsx("div",{id:`${B}-error`,className:"nice-field__error",role:"alert",children:q}),ee==="right"&&!q&&N&&e.jsx("div",{id:`${B}-helper`,className:"nice-field__helper",children:N})]}),ee!=="right"&&q&&e.jsx("div",{id:`${B}-error`,className:"nice-field__error",role:"alert",children:q}),ee!=="right"&&!q&&N&&e.jsx("div",{id:`${B}-helper`,className:"nice-field__helper",children:N})]})});Ln.displayName="NiceMention";exports.DEFAULT_ASPECT_RATIOS=Mn;exports.EMOJI_DATA=ht;exports.GRADIENT_PRESETS=xn;exports.NICE_COLOR_PRESET_KEYS=hn;exports.NiceAccountPicker=Nn;exports.NiceAddressInput=wn;exports.NiceCodeEditorAI=$i;exports.NiceColorPalette=fn;exports.NiceContactPicker=Cn;exports.NiceCropEditor=Tn;exports.NiceDateRangeBox=ti;exports.NiceDocumentEditor=vn;exports.NiceDropDownBox=Zn;exports.NiceEmojiPicker=Sn;exports.NiceGradientPicker=jn;exports.NiceHtmlEditorAI=fi;exports.NiceImageAnnotator=In;exports.NiceImageEditor=En;exports.NiceInputOtp=$n;exports.NiceInvoiceLineEditor=zn;exports.NiceKeyValueEditor=Di;exports.NiceKnob=nn;exports.NiceLogConsole=kn;exports.NiceLookup=Wn;exports.NiceMarkdownEditor=bn;exports.NiceMention=Ln;exports.NicePDFAnnotationEditor=Rn;exports.NicePickList=rn;exports.NiceRangeSlider=qn;exports.NiceScannerControl=An;exports.NiceScriptRunner=Ri;exports.NiceSignature=Ji;exports.NiceTreeSelect=sn;exports.NiceWiki=_n;exports.applyPreset=pt;exports.contrastRatio=mt;exports.cssToGradient=yn;exports.generateHarmony=ot;exports.generateVariations=mn;exports.gradientToCss=Nt;exports.hexToHsv=He;exports.hexToRgb=st;exports.hsvToHex=De;exports.hsvToRgb=cn;exports.randomPalette=pn;exports.rgbToHex=dn;exports.rgbToHsl=ln;exports.rgbToHsv=St;exports.wcagLevel=ut;