@nice2dev/ui-forms 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NicePinCodeInput-3WugpLHi-CTyDHOeZ.cjs +419 -0
- package/dist/NicePinCodeInput-3WugpLHi-D5Vvnmzl.js +11037 -0
- package/dist/NiceSavedQueryPanel-z29D7N_A-D8tnSKo-.cjs +596 -0
- package/dist/NiceSavedQueryPanel-z29D7N_A-K3YHc_8w.js +6745 -0
- package/dist/charts-ClxW-i5q-DoJYE4HW.cjs +546 -0
- package/dist/charts-ClxW-i5q-Dw-2ffUs.js +3880 -0
- package/dist/index-BMQ-F0zE-CGrCifaz.cjs +4504 -0
- package/dist/index-BMQ-F0zE-CTvr4Txe.js +41586 -0
- package/dist/index-DLdxrnF6.cjs +404 -0
- package/dist/index-Uxu6da8j.js +22571 -0
- package/dist/index.cjs +7365 -1
- package/dist/index.d.ts +297 -293
- package/dist/index.mjs +92830 -8
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),P=require("./index-DLdxrnF6.cjs"),a=require("react");function Rn(n,t=30){switch(n){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-t,180+t];case"analogous":return[0,-t,t];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 Mt(n,t={}){const i=t.size??16,r="currentColor",d="currentColor";if(t.rectangle||n==="shade-chain"||n==="monochromatic"){const U=Math.max(3,Math.min(7,t.count??5)),A=i*.1,b=i-A*2,C=Math.max(1.2,i/14),z=i/2,K=Array.from({length:U},(X,G)=>{const p=A+b*G/(U-1),L=.25+.75*G/(U-1);return e.jsx("circle",{cx:p,cy:z,r:C,fill:d,opacity:L},G)});return e.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:i/2-i/6,width:i-2,height:i/3,rx:i/6,fill:"none",stroke:r,strokeOpacity:.25}),K]})}const h=t.angles??Rn(n),y=i/2,w=i/2,M=i/2-2,S=Math.max(1.4,i/9);return e.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:y,cy:w,r:M,fill:"none",stroke:r,strokeOpacity:.25}),h.map((U,A)=>{const b=(U-90)*Math.PI/180,C=y+M*Math.cos(b),z=w+M*Math.sin(b);return e.jsx("circle",{cx:C,cy:z,r:S,fill:d},A)})]})}function St(n,t,i){return Math.max(t,Math.min(i,n))}function qt({h:n,s:t,v:i}){n=(n%360+360)%360;const r=i*t,d=r*(1-Math.abs(n/60%2-1)),h=i-r;let y=0,w=0,M=0;return n<60?(y=r,w=d):n<120?(y=d,w=r):n<180?(w=r,M=d):n<240?(w=d,M=r):n<300?(y=d,M=r):(y=r,M=d),{r:Math.round((y+h)*255),g:Math.round((w+h)*255),b:Math.round((M+h)*255)}}function _t({r:n,g:t,b:i}){n/=255,t/=255,i/=255;const r=Math.max(n,t,i),d=Math.min(n,t,i),h=r-d;let y=0;return h!==0&&(r===n?y=(t-i)/h%6:r===t?y=(i-n)/h+2:y=(n-t)/h+4,y=(y*60+360)%360),{h:y,s:r===0?0:h/r,v:r}}function Xt({r:n,g:t,b:i}){n/=255,t/=255,i/=255;const r=Math.max(n,t,i),d=Math.min(n,t,i),h=(r+d)/2;if(r===d)return{h:0,s:0,l:h};const y=r-d,w=h>.5?y/(2-r-d):y/(r+d);let M=0;return r===n?M=((t-i)/y+(t<i?6:0))/6:r===t?M=((i-n)/y+2)/6:M=((n-t)/y+4)/6,{h:M*360,s:w,l:h}}function rt(n){const t=n.replace("#",""),i=t.length===3?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t,r=parseInt(i,16);return{r:r>>16&255,g:r>>8&255,b:r&255}}function Gt({r:n,g:t,b:i}){return"#"+[n,t,i].map(r=>r.toString(16).padStart(2,"0")).join("")}function Re(n){return Gt(qt(n))}function Pe(n){return _t(rt(n))}function Jt(n,t){const i=[];for(let r=0;r<t;r++){const d=t<=1?.5:r/(t-1),h=St(n.s*(.3+d*.7),0,1),y=St(n.v*(1.2-d*.7),0,1);i.push(Re({h:n.h,s:h,v:y}))}return i}function kt(n,t){if(n==="custom"||n==="shade-chain")return[0];const i=t??30;switch(n){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function it(n,t,i){return kt(t,i).map(r=>((n+r)%360+360)%360)}function Et(n,t,i=.12){const r=Math.max(2,t),d=(r-1)/2,h=[];for(let y=0;y<r;y++){const w=(y-d)*i,M=Math.max(.05,Math.min(.98,n.v+w)),S=Math.max(.05,Math.min(1,n.s-Math.abs(w)*.25));h.push(Re({h:n.h,s:S,v:M}))}return h}function Tt({r:n,g:t,b:i}){const[r,d,h]=[n,t,i].map(y=>{const w=y/255;return w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4)});return .2126*r+.7152*d+.0722*h}function ct(n,t){const i=Tt(rt(n)),r=Tt(rt(t)),d=Math.max(i,r),h=Math.min(i,r);return(d+.05)/(h+.05)}function dt(n){return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA-lg":"Fail"}const Yt={"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 ut(n,t){const i=Yt[t];return n.map(r=>{const d=(i.sRange[0]+i.sRange[1])/2,h=(i.vRange[0]+i.vRange[1])/2;return Re({h:r,s:d,v:h})})}function Ln(){return Math.floor(Math.random()*360)}function Zt(n,t,i){const r=Ln(),d=it(r,n,i),h=[];for(let y=0;y<t;y++){const w=d[y%d.length],M=.55+Math.random()*.4,S=.5+Math.random()*.45;h.push(Re({h:w+(Math.random()-.5)*8,s:M,v:S}))}return h}const In=({hues:n,baseHue:t,onBaseHueChange:i,mode:r,distance:d,disabled:h})=>{const y=a.useCallback(A=>{if(h)return;const b=A.currentTarget.getBoundingClientRect(),C=A.clientX-b.left-120,z=A.clientY-b.top-120,K=(Math.atan2(z,C)*180/Math.PI+360)%360;i(Math.round(K))},[120,120,h,i]),w=[];for(let A=0;A<360;A+=2){const b=(A-1)*Math.PI/180,C=(A+1)*Math.PI/180,z=Re({h:A,s:1,v:1});w.push(e.jsx("path",{d:`M${120+55*Math.cos(b)},${120+55*Math.sin(b)} L${120+110*Math.cos(b)},${120+110*Math.sin(b)} A110,110 0 0,1 ${120+110*Math.cos(C)},${120+110*Math.sin(C)} L${120+55*Math.cos(C)},${120+55*Math.sin(C)} A55,55 0 0,0 ${120+55*Math.cos(b)},${120+55*Math.sin(b)} Z`,fill:z},A))}const M=`wheel-center-${r}`,S=n.map((A,b)=>{const C=A*Math.PI/180;return e.jsx("circle",{cx:120+82.5*Math.cos(C),cy:120+82.5*Math.sin(C),r:b===0?8:6,fill:Re({h:A,s:.85,v:.9}),stroke:b===0?"var(--bg-primary, #fff)":"var(--border-color, #ccc)",strokeWidth:b===0?3:2},b)});let U=null;if(r==="analogous"||r==="split-complementary"){const A=kt(r,d).slice(1).map((b,C)=>{const z=(t+b)*Math.PI/180;return e.jsx("line",{x1:120,y1:120,x2:120+82.5*Math.cos(z),y2:120+82.5*Math.sin(z),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${C}`)});U=e.jsx(e.Fragment,{children:A})}return e.jsxs("svg",{className:"nice-palette__wheel",viewBox:"0 0 240 240",width:240,height:240,onClick:y,style:{cursor:h?"default":"crosshair"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:M,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),w,e.jsx("circle",{cx:120,cy:120,r:53,fill:Re({h:t,s:.6,v:.85})}),e.jsx("circle",{cx:120,cy:120,r:53,fill:`url(#${M})`,opacity:.4}),U,S]})},An=({colors:n})=>{if(n.length<2)return null;const t=[];for(let i=0;i<n.length;i++){const r=ct(n[i],"var(--bg-primary, #ffffff)"),d=ct(n[i],"var(--text-primary, #000000)");t.push({a:n[i],b:"var(--bg-primary, #ffffff)",ratio:r,level:dt(r)}),t.push({a:n[i],b:"var(--text-primary, #000000)",ratio:d,level:dt(d)});for(let h=i+1;h<n.length;h++){const y=ct(n[i],n[h]);t.push({a:n[i],b:n[h],ratio:y,level:dt(y)})}}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:t.map((i,r)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:i.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:"vs"}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:i.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[i.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${i.level.toLowerCase().replace("-","")}`,children:i.level})]},r))})]})},zn=({hex:n})=>{const t=rt(n),i=Xt(t),r=_t(t);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",n.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",t.r,", ",t.g,", ",t.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(i.h),"°, ",Math.round(i.s*100),"%,"," ",Math.round(i.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(r.h),"°, ",Math.round(r.s*100),"%,"," ",Math.round(r.v*100),"%"]})]})},Pn={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},Hn={"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"},Wn=["monochromatic","shade-chain","complementary","split-complementary","analogous","triadic","tetradic","square","custom"],Qt="nice-palette-custom-schemes";function On(){if(typeof window>"u")return[];try{const n=window.localStorage.getItem(Qt);if(!n)return[];const t=JSON.parse(n);if(Array.isArray(t))return t}catch{}return[]}function Bn(n){if(!(typeof window>"u"))try{window.localStorage.setItem(Qt,JSON.stringify(n))}catch{}}const Kt=a.forwardRef(({id:n,className:t,style:i,accessMode:r,value:d,onChange:h,minColors:y=1,maxColors:w=8,harmonyMode:M,onHarmonyModeChange:S,distance:U,onDistanceChange:A,preset:b,onPresetChange:C,showWheel:z=!0,showContrast:K=!0,showInfo:X=!0,showPresets:G=!0,presets:p=[],showVariations:L=!0,showRandom:$=!0,variationCount:E=5,label:J,disabled:g,colorCount:k,shadeStep:v,onShadeStepChange:T,customSchemes:I,onCustomSchemesChange:W,persistCustomSchemes:x=!0},c)=>{const H=P.Cl(r,n),_=H==="hidden";(H==="disabled"||H==="readOnly")&&(g=!0);const j=P.nl(n),{t:l}=P.ue(),[o,m]=a.useState("analogous"),[s,u]=a.useState(30),[q,B]=a.useState(""),[V,le]=a.useState(0),[R,O]=a.useState(.12),[te,oe]=a.useState(null),[pe,fe]=a.useState(()=>I??(x?On():[])),[ve,ne]=a.useState(null),re=M??o,ce=U??s,ge=b??q,se=v??R,N=I??pe;a.useEffect(()=>{!I&&x&&Bn(pe)},[pe,I,x]);const D=a.useCallback(Y=>{fe(Y),W==null||W(Y)},[W]),Z=a.useCallback(Y=>{m(Y),S==null||S(Y)},[S]),he=a.useCallback(Y=>{u(Y),A==null||A(Y)},[A]),me=a.useCallback(Y=>{B(Y),Y&&(C==null||C(Y))},[C]),ae=a.useMemo(()=>["var(--color-primary, #3b82f6)","var(--color-error, #ef4444)","var(--color-success, #22c55e)"],[]),ie=d&&d.length>0?d:ae,ke=ie[0],be=a.useMemo(()=>Pe(ke),[ke]),Ee=a.useMemo(()=>it(be.h,re,ce),[be.h,re,ce]),je=a.useCallback((Y,ue,$e,F)=>{var we;const de=k??te??void 0,xe=de!==void 0?Math.max(y,Math.min(w,de)):void 0;if(ue==="shade-chain"){const Te=xe??Math.max(y,5),De=Et({h:Y,s:be.s||.7,v:be.v||.6},Te,se);h==null||h(De);return}let Ce;const ye=ue==="custom"&&ve?N.find(Te=>Te.id===ve):null;ye&&ye.angles.length>0?Ce=ye.angles.map(Te=>((Y+Te)%360+360)%360):Ce=it(Y,ue,$e);let _e;if(F&&Yt[F]?_e=ut(Ce,F):_e=Ce.map(Te=>Re({h:Te,s:be.s||.7,v:be.v||.85})),(we=ye==null?void 0:ye.lightnessOffsets)!=null&&we.length&&(_e=_e.map((Te,De)=>{var Ve;const Le=(Ve=ye.lightnessOffsets)==null?void 0:Ve[De];if(Le==null)return Te;const Ie=Pe(Te);return Re({h:Ie.h,s:Ie.s,v:Math.max(.05,Math.min(.98,Ie.v+Le))})})),xe!==void 0){for(;_e.length<xe;){const Te=_e[_e.length-1]||"#888888",De=Pe(Te);_e.push(Re({h:(De.h+18)%360,s:De.s,v:De.v}))}_e=_e.slice(0,xe)}else{for(;_e.length<y;)_e.push(_e[_e.length-1]||"var(--nice-text-secondary, #888888)");_e.length>w&&(_e=_e.slice(0,w))}h==null||h(_e)},[be.s,be.v,y,w,h,k,te,se,ve,N]),He=a.useCallback(Y=>{if(!g){if(re==="custom"){const ue=Re({h:Y,s:be.s||.7,v:be.v||.85}),$e=[...ie];$e[V]=ue,h==null||h($e);return}je(Y,re,ce,ge)}},[g,re,ce,ge,je,be.s,be.v,ie,V,h]),Oe=a.useCallback(Y=>{g||(Z(Y),Y!=="custom"&&je(be.h,Y,ce,ge))},[g,be.h,ce,ge,Z,je]),Ae=a.useCallback(Y=>{g||(he(Y),je(be.h,re,Y,ge))},[g,be.h,re,ge,he,je]),Be=a.useCallback(Y=>{if(g)return;me(Y);const ue=it(be.h,re,ce),$e=ut(ue,Y);h==null||h($e.slice(0,w))},[g,be.h,re,ce,w,me,h]),Xe=a.useCallback((Y,ue)=>{if(g)return;const $e=[...ie];$e[Y]=ue,h==null||h($e)},[g,ie,h]),Qe=a.useCallback(()=>{if(g||ie.length>=w)return;const Y=Pe(ie[ie.length-1]),ue=Re({h:(Y.h+30)%360,s:Y.s,v:Y.v});h==null||h([...ie,ue])},[g,ie,w,h]),Ke=a.useCallback(Y=>{if(g||ie.length<=y)return;const ue=ie.filter(($e,F)=>F!==Y);h==null||h(ue),V>=ue.length&&le(Math.max(0,ue.length-1))},[g,ie,y,h,V]),Ge=a.useCallback(()=>{if(g)return;const Y=Math.max(y,Math.min(w,kt(re).length)),ue=Zt(re,Y,ce);h==null||h(ue)},[g,y,w,re,ce,h]),Fe=a.useMemo(()=>{if(!L)return[];const Y=ie[V]||ie[0];return Jt(Pe(Y),E)},[L,ie,V,E]),Ue=ie[V]||ie[0],ze=a.useMemo(()=>{const Y=Pe(Ue);return Re({h:(Y.h+180)%360,s:Y.s,v:Y.v})},[Ue]);return _?null:e.jsxs("div",{ref:c,id:j,className:`nice-palette ${g?"nice-palette--disabled":""} ${t||""}`,style:i,children:[J&&e.jsx("div",{className:"nice-palette__label",children:J}),e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(P.Ze,{label:l("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:g,value:re==="custom"&&ve?`custom:${ve}`:re,onChange:Y=>{const ue=Array.isArray(Y)?Y[0]:Y;if(typeof ue=="string")if(ue.startsWith("custom:")){const $e=ue.slice(7);ne($e),Oe("custom")}else ne(null),Oe(ue)},options:[...Wn.map(Y=>({value:Y,label:Pn[Y]})),...N.map(Y=>({value:`custom:${Y.id}`,label:`★ ${Y.name}`}))],renderOption:(Y,ue)=>{const $e=String(Y.value),F=$e.startsWith("custom:"),de=F?N.find(Ce=>Ce.id===$e.slice(7)):null,xe=de?de.angles:void 0;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:Mt(F?"custom":$e,{angles:xe,size:16,count:k})}),e.jsx("span",{style:{fontWeight:ue?600:400},children:Y.label})]})}}),re==="shade-chain"&&e.jsx(P.Je,{label:l("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:se,onChange:Y=>{const ue=typeof Y=="number"?Y:Number(Y);Number.isNaN(ue)||(O(ue),T==null||T(ue),je(be.h,re,ce,ge))},showStepper:!0,disabled:g}),e.jsx(P.Je,{label:l("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,y),max:Math.min(12,w),step:1,precision:0,value:k??te??ie.length,onChange:Y=>{const ue=typeof Y=="number"?Y:Number(Y);if(!Number.isFinite(ue))return;const $e=Math.max(Math.max(2,y),Math.min(Math.min(12,w),Math.round(ue)));oe($e),re==="shade-chain"?h==null||h(Et({h:be.h,s:be.s||.7,v:be.v||.6},$e,se)):setTimeout(()=>je(be.h,re,ce,ge),0)},showStepper:!0,disabled:g})]}),e.jsxs("div",{className:"nice-palette__main",children:[z&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(In,{hues:Ee,baseHue:be.h,onBaseHueChange:He,mode:re,distance:ce,disabled:g}),(re==="analogous"||re==="split-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsxs("label",{children:["Distance: ",ce,"°"]}),e.jsx("input",{type:"range",min:10,max:90,value:ce,onChange:Y=>Ae(Number(Y.target.value)),disabled:g,className:"nice-palette__distance-slider"})]})]}),e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[ie.map((Y,ue)=>e.jsxs("div",{className:`nice-palette__swatch-wrapper ${V===ue?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>le(ue),children:[e.jsx("div",{className:"nice-palette__swatch",style:{background:Y},children:ie.length>y&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:$e=>{$e.stopPropagation(),Ke(ue)},disabled:g,"aria-label":"Remove color",children:"×"})}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:Y.toUpperCase(),maxLength:7,disabled:g,onChange:$e=>Xe(ue,$e.target.value)})]},ue)),ie.length<w&&e.jsx("button",{type:"button",className:"nice-palette__add-btn",onClick:Qe,disabled:g,title:"Add color",children:"+"})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:"Complementary"}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:ze},title:ze.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:ze.toUpperCase()})]}),L&&Fe.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:Fe.map((Y,ue)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:Y},title:Y.toUpperCase(),onClick:()=>{g||Xe(V,Y)},role:"button",tabIndex:0},ue))})]}),$&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ge,disabled:g,title:"Random palette","aria-label":"Random palette",children:"🎲 Random Palette"})]})]}),G&&p.length>0&&e.jsxs("div",{className:"nice-palette__presets",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Style Presets"}),e.jsx("div",{className:"nice-palette__preset-grid",children:p.map(Y=>{const ue=ut(Ee,Y);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${ge===Y?"nice-palette__preset-card--active":""}`,onClick:()=>Be(Y),disabled:g,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:ue.map(($e,F)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:$e}},F))}),e.jsx("span",{className:"nice-palette__preset-label",children:Hn[Y]})]},Y)})})]}),X&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:"Selected Color Info"}),e.jsx(zn,{hex:Ue})]}),e.jsxs("details",{className:"nice-palette__custom-schemes",style:{marginTop:8},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:["Custom schemes (",N.length,")"]}),e.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[N.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:l("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),N.map(Y=>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:Mt("custom",{angles:Y.angles,size:16})}),e.jsx("span",{style:{flex:1},children:Y.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{ne(Y.id),Oe("custom")},disabled:g,children:"Use"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>D(N.filter(ue=>ue.id!==Y.id)),disabled:g,"aria-label":`Delete ${Y.name}`,children:"×"})]},Y.id)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:g,onClick:()=>{const Y=typeof window<"u"?window.prompt("Scheme name?",`Scheme ${N.length+1}`):null;if(!Y)return;const ue=Pe(ie[0]).h,$e=ie.map(de=>(Pe(de).h-ue+540)%360-180),F={id:`cs-${Date.now()}`,name:Y,angles:$e};D([...N,F])},children:"+ Save current as scheme"}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:g||N.length===0,onClick:()=>{var Y;typeof navigator>"u"||((Y=navigator.clipboard)==null||Y.writeText(JSON.stringify(N,null,2)))},children:l("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:g,onClick:()=>{if(typeof window>"u")return;const Y=window.prompt("Paste schemes JSON");if(Y)try{const ue=JSON.parse(Y);Array.isArray(ue)&&D(ue)}catch{}},children:l("colorPalette.importJson","Import JSON")})]})]})]}),K&&e.jsxs("details",{className:"nice-palette__contrast-popup",style:{marginTop:8},children:[e.jsx("summary",{style:{cursor:"pointer",padding:"6px 10px",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-color)",borderRadius:4,display:"inline-block",fontSize:12,userSelect:"none"},children:"Contrast Analysis (WCAG 2.1)"}),e.jsx("div",{style:{marginTop:8},children:e.jsx(An,{colors:ie})})]})]})});Kt.displayName="NiceColorPalette";function bt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function xt(n){const t=n.stops.slice().sort((r,d)=>r.position-d.position).map(r=>`${r.color} ${r.position}%`).join(", "),i=n.repeating?"repeating-":"";switch(n.type){case"linear":return`${i}linear-gradient(${n.angle}deg, ${t})`;case"radial":{const r=n.shape||"ellipse",d=n.size||"farthest-corner",h=n.positionX??50,y=n.positionY??50;return`${i}radial-gradient(${r} ${d} at ${h}% ${y}%, ${t})`}case"conic":{const r=n.angle??0,d=n.positionX??50,h=n.positionY??50;return`${i}conic-gradient(from ${r}deg at ${d}% ${h}%, ${t})`}}}function en(n){var r,d,h;const t=n.trim(),i=t.startsWith("repeating-");if(t.includes("linear-gradient")){const y=(r=t.match(/linear-gradient\((.+)\)/))==null?void 0:r[1];if(!y)return null;const w=y.split(",").map(b=>b.trim());let M=90,S=0;const U=w[0].match(/^(\d+)deg$/);U&&(M=parseInt(U[1]),S=1);const A=mt(w.slice(S));return{type:"linear",angle:M,repeating:i,stops:A}}if(t.includes("radial-gradient")){const y=(d=t.match(/radial-gradient\((.+)\)/))==null?void 0:d[1];if(!y)return null;const w=y.split(",").map(S=>S.trim()),M=mt(w.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"radial",angle:0,repeating:i,stops:M.length>=2?M:bt().stops}}if(t.includes("conic-gradient")){const y=(h=t.match(/conic-gradient\((.+)\)/))==null?void 0:h[1];if(!y)return null;const w=y.split(",").map(S=>S.trim()),M=mt(w.filter(S=>S.includes("#")||S.includes("rgb")));return{type:"conic",angle:0,repeating:i,stops:M.length>=2?M:bt().stops}}return null}function mt(n){return n.map((t,i,r)=>{const d=t.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(d){const h=d[2]?parseFloat(d[2]):i/Math.max(1,r.length-1)*100;return{color:d[1],position:h}}return{color:t,position:i/Math.max(1,r.length-1)*100}})}function Fn(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function Un(n=2){const t=["linear","radial","conic"],i=t[Math.floor(Math.random()*t.length)],r=[];for(let d=0;d<n;d++)r.push({color:Fn(),position:Math.round(d/(n-1)*100)});return{type:i,angle:Math.floor(Math.random()*360),stops:r,shape:i==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:i!=="linear"?Math.round(Math.random()*100):void 0,positionY:i!=="linear"?Math.round(Math.random()*100):void 0}}const tn=[{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}}],nn=a.forwardRef(({id:n,className:t,style:i,accessMode:r,value:d,onChange:h,showCssOutput:y=!0,showPresets:w=!0,showEditor:M=!0,showRandom:S=!0,maxStops:U=10,label:A,disabled:b,width:C},z)=>{const K=P.Cl(r,n),X=K==="hidden";(K==="disabled"||K==="readOnly")&&(b=!0);const G=P.nl(n),p=d??bt(),L=a.useMemo(()=>xt(p),[p]),[$,E]=a.useState(0),[J,g]=a.useState(""),k=a.useRef(null),v=a.useCallback(s=>{h==null||h(s)},[h]),T=a.useCallback(s=>{b||v({...p,type:s})},[b,p,v]),I=a.useCallback(s=>{b||v({...p,angle:s})},[b,p,v]),W=a.useCallback(s=>{b||v({...p,repeating:s})},[b,p,v]),x=a.useCallback(s=>{b||v({...p,shape:s})},[b,p,v]),c=a.useCallback((s,u)=>{if(b)return;const q=p.stops.map((B,V)=>V===s?{...B,...u}:B);v({...p,stops:q})},[b,p,v]),H=a.useCallback(()=>{if(b||p.stops.length>=U)return;const s=p.stops.slice().sort((le,R)=>le.position-R.position);let u=0,q=s[0];for(let le=0;le<s.length-1;le++){const R=s[le+1].position-s[le].position;R>u&&(u=R,q=s[le])}const B=Math.round(q.position+u/2),V="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");v({...p,stops:[...p.stops,{color:V,position:B}]})},[b,p,U,v]),_=a.useCallback(s=>{if(b||p.stops.length<=2)return;const u=p.stops.filter((q,B)=>B!==s);v({...p,stops:u}),$>=u.length&&E(u.length-1)},[b,p,$,v]),j=a.useCallback(()=>{if(b)return;const s=2+Math.floor(Math.random()*3);v(Un(s))},[b,v]),l=a.useCallback(()=>{if(b||!J.trim())return;const s=en(J);s&&v(s)},[b,J,v]),o=a.useCallback(s=>{if(b||!k.current||p.stops.length>=U)return;const u=k.current.getBoundingClientRect(),q=Math.round((s.clientX-u.left)/u.width*100),B="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),V=[...p.stops,{color:B,position:q}];v({...p,stops:V}),E(V.length-1)},[b,p,U,v]),m=a.useMemo(()=>p.stops.slice().sort((s,u)=>s.position-u.position),[p.stops]);return X?null:e.jsxs("div",{ref:z,id:G,className:`nice-gradient ${b?"nice-gradient--disabled":""} ${t||""}`,style:{width:C!=null?typeof C=="number"?`${C}px`:C:320,boxSizing:"border-box",...i},children:[A&&e.jsx("div",{className:"nice-gradient__label",children:A}),e.jsx("div",{className:"nice-gradient__preview",style:{background:L}}),M&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(s=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${p.type===s?"nice-gradient__type-btn--active":""}`,onClick:()=>T(s),disabled:b,children:s.charAt(0).toUpperCase()+s.slice(1)},s)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:p.repeating??!1,onChange:s=>W(s.target.checked),disabled:b}),"Repeating"]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[p.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Angle: ",p.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:p.angle,onChange:s=>I(Number(s.target.value)),disabled:b,className:"nice-gradient__slider"}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(s=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${p.angle===s?"nice-gradient__angle-btn--active":""}`,onClick:()=>I(s),disabled:b,title:`${s}°`,children:e.jsx("span",{style:{transform:`rotate(${s}deg)`,display:"inline-block"},children:"→"})},s))})]}),p.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(s=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(p.shape||"ellipse")===s?"nice-gradient__shape-btn--active":""}`,onClick:()=>x(s),disabled:b,children:s},s))})]}),(p.type==="radial"||p.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Center: ",p.positionX??50,"%, ",p.positionY??50,"%"]}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:p.positionX??50,onChange:s=>v({...p,positionX:Number(s.target.value)}),disabled:b,className:"nice-gradient__slider"}),e.jsx("input",{type:"range",min:0,max:100,value:p.positionY??50,onChange:s=>v({...p,positionY:Number(s.target.value)}),disabled:b,className:"nice-gradient__slider"})]})]}),p.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsxs("label",{children:["Start angle: ",p.angle,"°"]}),e.jsx("input",{type:"range",min:0,max:360,value:p.angle,onChange:s=>I(Number(s.target.value)),disabled:b,className:"nice-gradient__slider"})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{ref:k,className:"nice-gradient__bar",style:{background:L},onClick:o,children:p.stops.map((s,u)=>e.jsx("div",{className:`nice-gradient__stop-marker ${$===u?"nice-gradient__stop-marker--active":""}`,style:{left:`${s.position}%`},onClick:q=>{q.stopPropagation(),E(u)},title:`${s.color} @ ${s.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:s.color}})},u))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:H,disabled:b||p.stops.length>=U,title:"Add stop",children:"+"})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:m.map((s,u)=>{const q=p.stops.indexOf(s);return e.jsxs("div",{className:`nice-gradient__stop-row ${$===q?"nice-gradient__stop-row--active":""}`,onClick:()=>E(q),children:[e.jsx("input",{type:"color",value:s.color,onChange:B=>c(q,{color:B.target.value}),disabled:b,className:"nice-gradient__stop-color"}),e.jsx("input",{type:"text",value:s.color.toUpperCase(),maxLength:7,onChange:B=>c(q,{color:B.target.value}),disabled:b,className:"nice-gradient__stop-hex"}),e.jsx("input",{type:"number",min:0,max:100,value:s.position,onChange:B=>c(q,{position:Number(B.target.value)}),disabled:b,className:"nice-gradient__stop-pos"}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),p.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>_(q),disabled:b,"aria-label":"Remove stop",children:"×"})]},q)})})})]}),S&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:j,disabled:b,title:"Random gradient","aria-label":"Random gradient",children:"🎲 Random Gradient"}),w&&e.jsxs("div",{className:"nice-gradient__presets",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"Presets"}),e.jsx("div",{className:"nice-gradient__preset-grid",children:tn.map((s,u)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{b||v(s.value)},disabled:b,title:s.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:xt(s.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:s.name})]},u))})]}),y&&e.jsxs("div",{className:"nice-gradient__css",children:[e.jsx("div",{className:"nice-gradient__section-title",children:"CSS Output"}),e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${L};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>{var s;return(s=navigator.clipboard)==null?void 0:s.writeText(`background: ${L};`)},title:"Copy CSS",children:"📋"})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:"Paste CSS gradient to import...",value:J,onChange:s=>g(s.target.value),disabled:b}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:l,disabled:b,children:"Import"})]})]})]})});nn.displayName="NiceGradientPicker";const Vn=({options:n,value:t,onChange:i,searchable:r=!0,clearable:d,loading:h,placeholder:y,label:w,error:M,helperText:S,required:U,disabled:A,size:b="md",id:C,className:z,style:K,data:X,columns:G,valueField:p="id",displayField:L,dropdownWidth:$,controlWidth:E})=>{var m;const J=P.nl(C),{t:g}=P.ue(),[k,v]=a.useState(!1),[T,I]=a.useState(""),W=a.useRef(null);P.sl(W,()=>v(!1));const x=!!(X&&G&&G.length>0),c=L??(G&&((m=G[0])==null?void 0:m.key)),H=a.useMemo(()=>!x||!X?[]:X.map(s=>({value:String(s[p]??""),label:c?String(s[c]??""):""})),[x,X,p,c]),_=x?H:n??[],j=_.find(s=>String(s.value)===t),l=a.useMemo(()=>{if(!x||!X)return[];if(!T)return X;const s=T.toLowerCase();return X.filter(u=>G.some(q=>String(u[q.key]??"").toLowerCase().includes(s)))},[x,X,G,T]),o=a.useMemo(()=>{if(x||!T)return _;const s=T.toLowerCase();return _.filter(u=>u.label.toLowerCase().includes(s))},[_,T,x]);return e.jsxs("div",{className:`nice-field nice-field--${b} ${M?"nice-field--error":""} ${z||""}`,style:{width:E!=null?typeof E=="number"?`${E}px`:E:"fit-content",...K},ref:W,children:[w&&e.jsxs("label",{className:"nice-field__label",htmlFor:J,children:[w,U&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__input-wrap",style:{position:"relative"},children:[e.jsxs("button",{type:"button",id:J,className:"nice-select__trigger",onClick:()=>!A&&v(!k),disabled:A,children:[e.jsx("span",{children:(j==null?void 0:j.label)||y||g("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),d&&t&&!A&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>i(""),"aria-label":g("controls.clear","Clear"),children:"✕"}),k&&e.jsxs("div",{className:"nice-dropdown nice-lookup__dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:50,marginTop:4,background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:"100%",width:$!=null?typeof $=="number"?`${$}px`:$:x?"max-content":"100%"},children:[r&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:T,onChange:s=>I(s.target.value),placeholder:g("controls.search","Search..."),autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--border-color)",borderRadius:4,background:"var(--bg-primary)",color:"var(--text-primary)"}})}),x?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",style:{width:"100%",borderCollapse:"collapse",color:"var(--text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:G.map(s=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--text-secondary)",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",width:s.width!=null?typeof s.width=="number"?`${s.width}px`:s.width:void 0},children:s.header},s.key))})}),e.jsx("tbody",{children:l.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:G.length,style:{padding:12,textAlign:"center",color:"var(--text-muted)"},children:g("controls.noResults","No results")})}):l.map(s=>{const u=String(s[p]??""),q=u===t;return e.jsx("tr",{role:"option","aria-selected":q,onClick:()=>{i(u),v(!1),I("")},style:{cursor:"pointer",background:q?"var(--hover-bg)":"transparent"},onMouseEnter:B=>{q||(B.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:B=>{q||(B.currentTarget.style.background="transparent")},children:G.map(B=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--border-color)"},children:String(s[B.key]??"")},B.key))},u)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto"},children:o.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--text-muted)"},children:g("controls.noResults","No results")}):o.map(s=>e.jsx("li",{role:"option",className:`nice-dropdown__option ${String(s.value)===t?"nice-dropdown__option--selected":""}`,onClick:()=>{i(String(s.value)),v(!1),I("")},"aria-selected":String(s.value)===t,children:s.label},String(s.value)))})]})]}),M&&e.jsx("div",{className:"nice-field__error",children:M}),S&&!M&&e.jsx("div",{className:"nice-field__hint",children:S})]})},qn=["Su","Mo","Tu","We","Th","Fr","Sa"];function Xn(n,t){return new Date(n,t+1,0).getDate()}function Gn(n,t){return new Date(n,t,1).getDay()}function Dt(n,t,i){return`${n}-${String(t+1).padStart(2,"0")}-${String(i).padStart(2,"0")}`}function Jn(n){const t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()));t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));const i=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-i.getTime())/864e5+1)/7)}const Rt=["January","February","March","April","May","June","July","August","September","October","November","December"],an=({value:n,onChange:t,min:i,max:r,disabledDates:d=[],firstDayOfWeek:h=1,size:y="md",showWeekNumbers:w,onMonthChange:M,className:S,style:U,accessMode:A,id:b,multiple:C,selectedDates:z=[],onSelectedDatesChange:K,renderDay:X,showKeyboardHints:G,persistPreferences:p=!1,fullWidth:L=!1,cookies:$=!1,localStorage:E=!0,sessionStorage:J=!1,storageMode:g,storageKey:k})=>{const v=P.Cl(A,b),T=v==="hidden",I=v==="disabled"||v==="readOnly",{t:W}=P.ue(),x=new Date,c=n?new Date(n):x,H=P.fr(k??"nice-calendar"),_=a.useMemo(()=>p?H.get("prefs")??{}:{},[p,H]),j=_.firstDayOfWeek??h,[l,o]=a.useState(_.lastViewYear??c.getFullYear()),[m,s]=a.useState(_.lastViewMonth??c.getMonth()),[u,q]=a.useState(_.preferredView??"days"),B=a.useCallback(ae=>{if(!p)return;const ie=H.get("prefs")??{};H.set("prefs",{...ie,...ae})},[p,H]),V=a.useCallback(ae=>{q(ae),B({preferredView:ae})},[B]),le=a.useCallback((ae,ie)=>{B({lastViewYear:ae,lastViewMonth:ie})},[B]),R=a.useMemo(()=>[P.Bl.moveUp,P.Bl.moveDown,P.Bl.moveLeft,P.Bl.moveRight,{key:"Enter",description:W("shortcuts.selectDate","Select date")},P.Bl.pageUp,P.Bl.pageDown],[W]),O=a.useMemo(()=>Xn(l,m),[l,m]),te=a.useMemo(()=>(Gn(l,m)-j+7)%7,[l,m,j]),oe=a.useMemo(()=>{const ae=[...qn];for(let ie=0;ie<j;ie++)ae.push(ae.shift());return ae},[j]),pe=a.useCallback(ae=>i&&ae<i||r&&ae>r?!0:d.includes(ae),[i,r,d]),fe=a.useCallback(ae=>{if(u==="years"){o(be=>be+ae*10);return}if(u==="months"){o(be=>be+ae);return}let ie=m+ae,ke=l;ie<0&&(ie=11,ke--),ie>11&&(ie=0,ke++),s(ie),o(ke),le(ke,ie),M==null||M(ke,ie)},[m,l,M,u,le]),ve=Dt(x.getFullYear(),x.getMonth(),x.getDate()),ne=a.useCallback(ae=>C?z.includes(ae):ae===n,[C,z,n]),re=a.useCallback(ae=>{if(!I){if(C){const ie=z.includes(ae)?z.filter(ke=>ke!==ae):[...z,ae];K==null||K(ie)}t==null||t(ae)}},[C,z,t,K]),ce=a.useCallback(()=>{u==="days"?V("months"):u==="months"&&V("years")},[u,V]),ge=a.useCallback(ae=>{s(ae),V("days"),le(l,ae),M==null||M(l,ae)},[l,M,V,le]),se=a.useCallback(ae=>{o(ae),V("months")},[V]),N=u==="years"?`${l-l%10} – ${l-l%10+9}`:u==="months"?`${l}`:`${Rt[m]} ${l}`,D=u==="years"?"decade":u==="months"?"year":"month",Z=[];for(let ae=0;ae<te;ae++)Z.push(null);for(let ae=1;ae<=O;ae++)Z.push(ae);for(;Z.length%7!==0;)Z.push(null);const he=[];for(let ae=0;ae<Z.length;ae+=7)he.push(Z.slice(ae,ae+7));const me=l-l%10;return T?null:e.jsxs("div",{className:`nice-calendar nice-calendar--${y}${L?" nice-calendar--full-width":""} ${S||""}`,style:U,children:[e.jsxs("div",{className:"nice-calendar__header",children:[e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>fe(-1),"aria-label":`Previous ${D}`,children:"‹"}),e.jsx("button",{type:"button",className:"nice-calendar__title",onClick:ce,"aria-label":u==="days"?"Show month picker":u==="months"?"Show year picker":void 0,disabled:u==="years",children:N}),e.jsx("button",{type:"button",className:"nice-calendar__nav",onClick:()=>fe(1),"aria-label":`Next ${D}`,children:"›"}),G&&e.jsx(P.Ba,{shortcuts:R,size:"sm"})]}),u==="days"&&e.jsxs("table",{className:"nice-calendar__grid",role:"grid",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[w&&e.jsx("th",{className:"nice-calendar__wk",children:"W"}),oe.map(ae=>e.jsx("th",{children:ae},ae))]})}),e.jsx("tbody",{children:he.map((ae,ie)=>e.jsxs("tr",{children:[w&&e.jsx("td",{className:"nice-calendar__wk",children:ae.find(ke=>ke!=null)?Jn(new Date(l,m,ae.find(ke=>ke!=null))):""}),ae.map((ke,be)=>{if(ke==null)return e.jsx("td",{className:"nice-calendar__empty-cell"},be);const Ee=Dt(l,m,ke),je=pe(Ee),He=ne(Ee);return e.jsx("td",{className:`nice-calendar__day${He?" nice-calendar__day--selected":""}${Ee===ve?" nice-calendar__day--today":""}${je?" nice-calendar__day--disabled":""}`,onClick:()=>!je&&re(Ee),role:"gridcell","aria-selected":He,"aria-disabled":je,children:X?X(Ee,ke):ke},be)})]},ie))})]}),u==="months"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Rt.map((ae,ie)=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${ie===m&&l===c.getFullYear()?" nice-calendar__picker-cell--selected":""}`,onClick:()=>ge(ie),children:ae.slice(0,3)},ie))}),u==="years"&&e.jsx("div",{className:"nice-calendar__picker-grid",children:Array.from({length:12},(ae,ie)=>me-1+ie).map(ae=>e.jsx("button",{type:"button",className:`nice-calendar__picker-cell${ae===l?" nice-calendar__picker-cell--selected":""}${ae<me||ae>me+9?" nice-calendar__picker-cell--other":""}`,onClick:()=>se(ae),children:ae},ae))})]})};an.displayName="NiceCalendar";const Yn=({startDate:n,endDate:t,onStartChange:i,onEndChange:r,min:d,max:h,clearable:y,startPlaceholder:w,endPlaceholder:M,startLabel:S,endLabel:U,layout:A="horizontal",separator:b="–",gap:C=12,fullWidth:z=!1,label:K,error:X,helperText:G,required:p,disabled:L,size:$="md",id:E,className:J,style:g,accessMode:k,showKeyboardHints:v,labelPlacement:T,errorPlacement:I,labelWidth:W,controlWidth:x,loading:c})=>{const H=P.Cl(k,E),_=P.nl(E),{t:j}=P.ue(),l=H==="disabled"||H==="readOnly"||!!L,o=a.useMemo(()=>[{key:"Tab",description:j("shortcuts.switchField","Switch between start/end")},P.Bl.cancel],[j]);if(H==="hidden")return null;const m=u=>{i(u),u&&t&&u>t&&r(u)},s=A==="horizontal";return e.jsxs("div",{className:`nice-field nice-field--${$} nice-daterange nice-daterange--${A} ${T==="left"?"nice-field--label-left":""} ${X?"nice-field--error":""} ${c?"nice-field--loading":""} ${J||""}`,style:{...g,...W!=null&&{"--nice-field-label-width":typeof W=="number"?`${W}px`:W},...x!=null&&{"--nice-field-control-width":typeof x=="number"?`${x}px`:x}},"aria-busy":c||void 0,children:[K&&e.jsxs("label",{className:"nice-field__label",htmlFor:_,children:[K,p&&e.jsx("span",{className:"nice-field__required",children:"*"}),v&&e.jsx(P.Ba,{shortcuts:o,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:s?"row":"column",alignItems:s?"flex-end":"stretch",gap:C,flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:z?"1 1 0":void 0,minWidth:0},children:e.jsx(P.sn,{id:_,label:S,value:n,onChange:m,min:d,max:t||h,placeholder:w||j("controls.startDate","Start date"),disabled:l,size:$,clearable:y,labelPlacement:T,labelWidth:W})}),s&&b!==""&&b!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--text-secondary, #666)"},"aria-hidden":"true",children:b}),e.jsx("div",{style:{flex:z?"1 1 0":void 0,minWidth:0},children:e.jsx(P.sn,{label:U,value:t,onChange:r,min:n||d,max:h,placeholder:M||j("controls.endDate","End date"),disabled:l,size:$,clearable:y,labelPlacement:T,labelWidth:W})})]}),c&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),I==="right"&&X&&e.jsx("div",{className:"nice-field__error",role:"alert",children:X}),I==="right"&&!X&&G&&e.jsx("div",{className:"nice-field__helper",children:G})]}),I!=="right"&&X&&e.jsx("div",{className:"nice-field__error",children:X}),I!=="right"&&!X&&G&&e.jsx("div",{className:"nice-field__hint",children:G})]})},Zn=({min:n=0,max:t=100,step:i=1,startValue:r,endValue:d,onChange:h,showLabels:y=!0,formatLabel:w,valuePlacement:M="none",label:S,error:U,helperText:A,required:b,disabled:C,readOnly:z,loading:K,size:X="md",id:G,className:p,style:L,accessMode:$,showKeyboardHints:E,labelPlacement:J,errorPlacement:g,labelWidth:k,controlWidth:v})=>{const T=P.Cl($,G),I=T==="hidden";(T==="disabled"||T==="readOnly")&&(C=!0);const{t:W}=P.ue(),x=P.nl(G),c=a.useRef(null),H=a.useMemo(()=>[P.Bl.increment,P.Bl.decrement,P.Bl.first,P.Bl.last,{key:"Tab",description:W("shortcuts.switchThumb","Switch thumb")}],[W]),_=m=>(m-n)/(t-n)*100,j=m=>w?w(m):String(m),l=m=>{const s=Math.round(m/i)*i;return Math.max(n,Math.min(t,s))},o=a.useCallback((m,s)=>{m.preventDefault();const u=c.current;if(!u||C)return;const q=V=>{const le=u.getBoundingClientRect(),R=Math.max(0,Math.min(1,(V.clientX-le.left)/le.width)),O=l(n+R*(t-n));s==="start"?h(Math.min(O,d),d):h(r,Math.max(O,r))},B=()=>{document.removeEventListener("pointermove",q),document.removeEventListener("pointerup",B)};document.addEventListener("pointermove",q),document.addEventListener("pointerup",B)},[n,t,i,r,d,h,C]);return I?null:e.jsxs("div",{className:`nice-field nice-field--${X} nice-field--rangeslider ${J==="left"?"nice-field--label-left":""} ${g==="right"?"nice-field--error-right":""} ${U?"nice-field--error":""} ${K?"nice-field--loading":""} ${p||""}`,style:{...L,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...v!=null&&{"--nice-field-control-width":typeof v=="number"?`${v}px`:v}},"aria-busy":K||void 0,children:[S&&e.jsxs("label",{className:"nice-field__label nice-field__label--with-value",htmlFor:x,children:[e.jsxs("span",{className:"nice-field__label-text",children:[S,b&&e.jsx("span",{className:"nice-field__required",children:"*"}),E&&e.jsx(P.Ba,{shortcuts:H,size:"sm"})]}),M==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[j(r)," – ",j(d)]})]}),e.jsxs("div",{className:"nice-field__control",children:[M==="right"&&!S&&e.jsxs("span",{className:"nice-range-slider__value",children:[j(r)," – ",j(d)]}),e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${y?"nice-range-slider--with-labels":""} ${S?"nice-range-slider--has-field-label":""}`,ref:c,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${_(r)}%`,width:`${_(d)-_(r)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${_(r)}%`},onPointerDown:m=>z?void 0:o(m,"start"),role:"slider","aria-valuemin":n,"aria-valuemax":d,"aria-valuenow":r,tabIndex:C?-1:0,id:x}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${_(d)}%`},onPointerDown:m=>z?void 0:o(m,"end"),role:"slider","aria-valuemin":r,"aria-valuemax":t,"aria-valuenow":d,tabIndex:C?-1:0})]}),y&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${_(r)}%`},children:j(r)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${_(d)}%`},children:j(d)})]}),M==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[j(r)," – ",j(d)]})]}),K&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),g==="right"&&U&&e.jsx("div",{className:"nice-field__error",role:"alert",children:U}),g==="right"&&!U&&A&&e.jsx("div",{className:"nice-field__helper",children:A})]}),g!=="right"&&U&&e.jsx("div",{className:"nice-field__error",role:"alert",children:U}),g!=="right"&&!U&&A&&e.jsx("div",{className:"nice-field__helper",children:A})]})},Qn=({displayValue:n,placeholder:t,clearable:i,children:r,onClear:d,open:h,onOpenChange:y,dropdownWidth:w,label:M,error:S,helperText:U,required:A,disabled:b,size:C="md",id:z,className:K,style:X,accessMode:G,showKeyboardHints:p,displayStyle:L})=>{P.Us("input",L),P.Ks("input",L);const $=P.Cl(G,z),E=$==="hidden";($==="disabled"||$==="readOnly")&&(b=!0);const J=P.nl(z),{t:g}=P.ue(),[k,v]=a.useState(!1),T=a.useRef(null),I=h??k,W=a.useMemo(()=>[{key:"Enter",description:g("shortcuts.openDropdown","Open dropdown")},P.Bl.cancel],[g]),x=c=>{y?y(c):v(c)};return P.sl(T,()=>x(!1)),E?null:e.jsxs("div",{className:`nice-field nice-field--${C} ${S?"nice-field--error":""} ${K||""}`,style:X,ref:T,children:[M&&e.jsxs("label",{className:"nice-field__label",htmlFor:J,children:[M,A&&e.jsx("span",{className:"nice-field__required",children:"*"}),p&&e.jsx(P.Ba,{shortcuts:W,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",children:[e.jsxs("button",{type:"button",id:J,className:"nice-select__trigger",onClick:()=>!b&&x(!I),disabled:b,children:[e.jsx("span",{children:n||t||g("controls.select","Select...")}),e.jsx("span",{className:"nice-select__arrow",children:"▾"})]}),i&&n&&!b&&e.jsx("button",{type:"button",className:"nice-field__clear",onClick:()=>d==null?void 0:d(),"aria-label":g("controls.clear","Clear"),children:"✕"})]}),I&&e.jsx("div",{className:"nice-dropdown",style:{width:w},children:r}),S&&e.jsx("div",{className:"nice-field__error",children:S}),U&&!S&&e.jsx("div",{className:"nice-field__hint",children:U})]})};function Lt(n){const t=n.trim().toLowerCase();return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("/")||t.startsWith("./")||t.startsWith("../")?!0:!(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:text"))}const Kn=["bold","italic","underline","strikethrough","h1","h2","h3","ul","ol","blockquote","hr","link","unlink","image","table","code","alignLeft","alignCenter","alignRight","fontSize","fontColor","undo","redo","clear","findReplace","emoji","source","fullscreen","markdown"],Me=({d:n,viewBox:t="0 0 24 24"})=>e.jsx("svg",{width:"16",height:"16",viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:n})}),ea={bold:e.jsx("strong",{style:{fontFamily:"serif"},children:"B"}),italic:e.jsx("em",{style:{fontFamily:"serif"},children:"I"}),underline:e.jsx("span",{style:{textDecoration:"underline"},children:"U"}),strikethrough:e.jsx("span",{style:{textDecoration:"line-through"},children:"S"}),h1:"H1",h2:"H2",h3:"H3",ul:e.jsx(Me,{d:"M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01"}),ol:e.jsx(Me,{d:"M10 6h11M10 12h11M10 18h11M4 6h1v4M4 10h2M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"}),link:e.jsx(Me,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"}),unlink:e.jsx(Me,{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07L11 5.78M3 3l18 18M9 15l3-3M14 11l3 3M14 21l-1.72-1.72a5 5 0 0 1-7.07-7.07L7 10.49"}),undo:e.jsx(Me,{d:"M3 7v6h6M3 13a9 9 0 1 0 3-7.7L3 13"}),redo:e.jsx(Me,{d:"M21 7v6h-6M21 13a9 9 0 1 1-3-7.7L21 13"}),clear:e.jsx(Me,{d:"M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),table:e.jsx(Me,{d:"M3 3h18v18H3zM3 9h18M3 15h18M9 3v18M15 3v18"}),image:e.jsx(Me,{d:"M3 3h18v18H3zM3 16l5-5 4 4 3-3 6 6M9 9a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"}),code:e.jsx(Me,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),markdown:"MD",blockquote:e.jsx(Me,{d:"M3 21c3-3 3-9 0-12M21 21c-3-3-3-9 0-12M9 7h6v6H9zM15 7h6v6h-6z"}),hr:e.jsx(Me,{d:"M5 12h14"}),subscript:"X₂",superscript:"X²",indent:e.jsx(Me,{d:"M3 8l4 4-4 4M7 6h14M7 12h14M3 18h18"}),outdent:e.jsx(Me,{d:"M7 8l-4 4 4 4M21 6H3M21 12H7M21 18H3"}),alignLeft:e.jsx(Me,{d:"M3 6h18M3 12h12M3 18h18"}),alignCenter:e.jsx(Me,{d:"M3 6h18M6 12h12M3 18h18"}),alignRight:e.jsx(Me,{d:"M3 6h18M9 12h12M3 18h18"}),alignJustify:e.jsx(Me,{d:"M3 6h18M3 12h18M3 18h18"}),fullscreen:e.jsx(Me,{d:"M3 9V3h6M21 9V3h-6M3 15v6h6M21 15v6h-6"}),removeFormat:e.jsx(Me,{d:"M4 7V4h16v3M5 20h6M13 4 8 20"}),print:e.jsx(Me,{d:"M6 9V2h12v7M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 14h12v8H6z"}),source:e.jsx(Me,{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"}),emoji:e.jsx(Me,{d:"M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zM8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01"}),findReplace:e.jsx(Me,{d:"M11 19a8 8 0 1 1 0-16 8 8 0 0 1 0 16zM21 21l-4.35-4.35"}),fontSize:e.jsx(Me,{d:"M4 7V4h16v3M9 20h6M12 4v16"}),fontColor:e.jsx(Me,{d:"M4 21h16M5 17l7-12 7 12M8 13h8"})},ta=[{value:"1",label:"8pt"},{value:"2",label:"10pt"},{value:"3",label:"12pt"},{value:"4",label:"14pt"},{value:"5",label:"18pt"},{value:"6",label:"24pt"},{value:"7",label:"36pt"}],na=[{label:"Faces",emojis:["??","??","??","??","??","??","??","??","??","??","??","??"]},{label:"Hands",emojis:["??","??","??","??","??","??","??","??","??","??"]},{label:"Symbols",emojis:["??","?","??","?","?","?","??","??","??","??","??","??"]},{label:"Arrows",emojis:["??","??","??","??","??","??","??","??","??","?"]}];function aa(n){let t=n;return t=t.replace(/<h1[^>]*>(.*?)<\/h1>/gi,`# $1
|
|
2
|
+
`),t=t.replace(/<h2[^>]*>(.*?)<\/h2>/gi,`## $1
|
|
3
|
+
`),t=t.replace(/<h3[^>]*>(.*?)<\/h3>/gi,`### $1
|
|
4
|
+
`),t=t.replace(/<strong[^>]*>(.*?)<\/strong>/gi,"**$1**"),t=t.replace(/<b[^>]*>(.*?)<\/b>/gi,"**$1**"),t=t.replace(/<em[^>]*>(.*?)<\/em>/gi,"*$1*"),t=t.replace(/<i[^>]*>(.*?)<\/i>/gi,"*$1*"),t=t.replace(/<code[^>]*>(.*?)<\/code>/gi,"`$1`"),t=t.replace(/<pre[^>]*>(.*?)<\/pre>/gis,"```\n$1\n```\n"),t=t.replace(/<br\s*\/?>/gi,`
|
|
5
|
+
`),t=t.replace(/<li[^>]*>(.*?)<\/li>/gi,`- $1
|
|
6
|
+
`),t=t.replace(/<\/?(?:ul|ol|p|div)[^>]*>/gi,`
|
|
7
|
+
`),t=t.replace(/<[^>]+>/g,""),t=t.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`),t.trim()}function ia(n){let t=n;return t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^# (.+)$/gm,"<h1>$1</h1>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/```\n?([\s\S]*?)\n?```/g,"<pre>$1</pre>"),t=t.replace(/^- (.+)$/gm,"<li>$1</li>"),t=t.replace(/(<li>.*<\/li>)/gs,"<ul>$1</ul>"),t=t.replace(/\n/g,"<br>"),t}const jt=({value:n,onChange:t,placeholder:i,height:r=200,toolbar:d=Kn,readOnly:h,onImageUpload:y,mentionTrigger:w,mentionSuggestions:M,onMentionSearch:S,onFileDrop:U,pasteCleanup:A=!0,maxLength:b=0,showWordCount:C=!1,templates:z,label:K,error:X,helperText:G,required:p,disabled:L,size:$="md",id:E,className:J,style:g,accessMode:k})=>{const v=P.Cl(k,E),T=v==="hidden";v==="disabled"&&(L=!0),v==="readOnly"&&(h=!0);const I=P.nl(E),W=a.useRef(null),x=a.useRef(null),c=a.useRef(null),[H,_]=a.useState(!1),[j,l]=a.useState(""),[o,m]=a.useState(!1),[s,u]=a.useState(""),[q,B]=a.useState(!1),[V,le]=a.useState(""),[R,O]=a.useState(0),[te,oe]=a.useState(!1),[pe,fe]=a.useState("var(--nice-text, #000000)"),[ve,ne]=a.useState("var(--nice-warning, #ffff00)"),[re,ce]=a.useState(0),[ge,se]=a.useState(0),[N,D]=a.useState(!1),[Z,he]=a.useState(""),[me,ae]=a.useState(""),[ie,ke]=a.useState(!1),[be,Ee]=a.useState(!1),je=a.useCallback((F,de)=>{var Ce,ye,_e;if(h||L)return;const xe=W.current;if(xe){if(F==="markdown"){if(!H)l(aa(n)),_(!0),m(!1);else{const we=ia(j);t(we),_(!1)}return}if(F==="source"){o?(t(s),m(!1)):(u(n),m(!0),_(!1));return}if(F==="fullscreen"){oe(we=>!we);return}if(F==="emoji"){ke(we=>!we);return}if(F==="findReplace"){D(we=>!we);return}if(F==="image"){if(y)(Ce=x.current)==null||Ce.click();else{const we=prompt("Image URL:");we&&Lt(we)&&(xe.focus(),document.execCommand("insertImage",!1,we),t(P.Ys(xe.innerHTML)))}return}switch(xe.focus(),F){case"bold":document.execCommand("bold");break;case"italic":document.execCommand("italic");break;case"underline":document.execCommand("underline");break;case"strikethrough":document.execCommand("strikeThrough");break;case"h1":document.execCommand("formatBlock",!1,"h1");break;case"h2":document.execCommand("formatBlock",!1,"h2");break;case"h3":document.execCommand("formatBlock",!1,"h3");break;case"ul":document.execCommand("insertUnorderedList");break;case"ol":document.execCommand("insertOrderedList");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"hr":document.execCommand("insertHorizontalRule");break;case"subscript":document.execCommand("subscript");break;case"superscript":document.execCommand("superscript");break;case"indent":document.execCommand("indent");break;case"outdent":document.execCommand("outdent");break;case"alignLeft":document.execCommand("justifyLeft");break;case"alignCenter":document.execCommand("justifyCenter");break;case"alignRight":document.execCommand("justifyRight");break;case"alignJustify":document.execCommand("justifyFull");break;case"removeFormat":document.execCommand("removeFormat");break;case"print":window.print();return;case"link":{const we=prompt("URL:");we&&Lt(we)&&document.execCommand("createLink",!1,we);break}case"unlink":document.execCommand("unlink");break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break;case"clear":document.execCommand("removeFormat");break;case"fontSize":{de&&document.execCommand("fontSize",!1,de);break}case"fontColor":{de&&document.execCommand("foreColor",!1,de);break}case"bgColor":{de&&document.execCommand("hiliteColor",!1,de);break}case"table":{document.execCommand("insertHTML",!1,'<table class="nice-htmleditor__table"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td> </td><td> </td><td> </td></tr><tr><td> </td><td> </td><td> </td></tr></tbody></table><p> </p>');break}case"code":{const we=((ye=window.getSelection())==null?void 0:ye.toString())||"";we.includes(`
|
|
10
|
+
`)||we.length>60?document.execCommand("insertHTML",!1,`<pre class="nice-htmleditor__code-block">${we||"// code"}</pre>`):document.execCommand("insertHTML",!1,`<code>${we||"code"}</code>`);break}}t(P.Ys(xe.innerHTML)),ce(((_e=xe.textContent)==null?void 0:_e.length)??0)}},[t,h,L,H,j,n,y,o,s]),He=a.useCallback(async F=>{var ye;const de=(ye=F.target.files)==null?void 0:ye[0];if(!de||!y)return;const xe=await y(de),Ce=W.current;Ce&&xe&&(Ce.focus(),document.execCommand("insertImage",!1,xe),t(Ce.innerHTML)),F.target.value=""},[y,t]),Oe=a.useCallback(()=>{var xe;const F=W.current;if(!F)return;const de=((xe=F.textContent)==null?void 0:xe.length)??0;if(b>0&&de>b&&(F.textContent=(F.textContent??"").slice(0,b)),ce(de),se((F.textContent??"").trim().split(/\s+/).filter(Boolean).length),t(F.innerHTML),w){const Ce=window.getSelection();if(Ce&&Ce.rangeCount>0){const ye=Ce.getRangeAt(0),_e=ye.startContainer;if(_e.nodeType===Node.TEXT_NODE){const we=_e.textContent||"",Te=ye.startOffset,De=we.slice(0,Te),Le=De.lastIndexOf(w);if(Le>=0&&(Le===0||/\s/.test(De[Le-1]))){const Ie=De.slice(Le+w.length);if(!/\s/.test(Ie)){B(!0),le(Ie),O(0),S==null||S(Ie);return}}}}B(!1)}},[t,w,S]),Ae=(M==null?void 0:M.filter(F=>F.label.toLowerCase().includes(V.toLowerCase())).slice(0,8))??[],Be=a.useCallback(F=>{var _e;const de=W.current;if(!de)return;const xe=window.getSelection();if(!xe||xe.rangeCount===0)return;const Ce=xe.getRangeAt(0),ye=Ce.startContainer;if(ye.nodeType===Node.TEXT_NODE&&w){const we=ye.textContent||"",Te=Ce.startOffset,De=we.slice(0,Te).lastIndexOf(w);if(De>=0){const Le=we.slice(0,De),Ie=we.slice(Te),Ve=`<span class="nice-htmleditor__mention" data-mention="${F.key}" contenteditable="false">${w}${F.label}</span> `;ye.textContent=Le;const Je=document.createRange();Je.setStartAfter(ye),Je.collapse(!0);const lt=Je.createContextualFragment(Ve+Ie);(_e=ye.parentNode)==null||_e.insertBefore(lt,ye.nextSibling),xe.collapseToEnd(),t(de.innerHTML)}}B(!1)},[w,t]),Xe=a.useCallback(F=>{if(q&&Ae.length>0){F.key==="ArrowDown"?(F.preventDefault(),O(de=>Math.min(de+1,Ae.length-1))):F.key==="ArrowUp"?(F.preventDefault(),O(de=>Math.max(de-1,0))):F.key==="Enter"?(F.preventDefault(),Be(Ae[R])):F.key==="Escape"&&B(!1);return}(F.ctrlKey||F.metaKey)&&F.key==="b"?(F.preventDefault(),je("bold")):(F.ctrlKey||F.metaKey)&&F.key==="i"?(F.preventDefault(),je("italic")):(F.ctrlKey||F.metaKey)&&F.key==="u"?(F.preventDefault(),je("underline")):(F.ctrlKey||F.metaKey)&&F.key==="f"?(F.preventDefault(),D(de=>!de)):(F.ctrlKey||F.metaKey)&&F.key==="z"&&!F.shiftKey?(F.preventDefault(),je("undo")):(F.ctrlKey||F.metaKey)&&(F.key==="y"||F.key==="z"&&F.shiftKey)&&(F.preventDefault(),je("redo"))},[q,Ae,R,Be,je]),Qe=a.useCallback(F=>{var ye;if(!A)return;F.preventDefault();const de=F.clipboardData.getData("text/html"),xe=F.clipboardData.getData("text/plain");if(de){const _e=de.replace(/<style[\s\S]*?<\/style>/gi,"").replace(/<script[\s\S]*?<\/script>/gi,"").replace(/class="[^"]*"/gi,"").replace(/style="[^"]*"/gi,"").replace(/<o:[^>]*>[\s\S]*?<\/o:[^>]*>/gi,"").replace(/<!--[\s\S]*?-->/g,"").replace(/<\/?(?:xml|meta|link|font|span)[^>]*>/gi,"");document.execCommand("insertHTML",!1,_e)}else xe&&document.execCommand("insertText",!1,xe);const Ce=W.current;Ce&&(t(Ce.innerHTML),ce(((ye=Ce.textContent)==null?void 0:ye.length)??0))},[A,t]),Ke=a.useCallback(async F=>{if(!U)return;F.preventDefault();const de=Array.from(F.dataTransfer.files);if(de.length===0)return;const xe=await U(de),Ce=W.current;if(Ce){Ce.focus();for(const ye of xe)if(/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(ye)||ye.startsWith("data:image/"))document.execCommand("insertImage",!1,ye);else{const _e=`<a href="${ye}">${ye.split("/").pop()??ye}</a>`;document.execCommand("insertHTML",!1,_e)}t(Ce.innerHTML)}},[U,t]),Ge=a.useCallback(F=>{U&&F.preventDefault()},[U]),Fe=a.useCallback(F=>{var _e;const de=W.current;if(!de||!Z)return;const xe=de.textContent??"",Ce=Z.toLowerCase(),ye=xe.toLowerCase();(F===1?ye.indexOf(Ce):ye.lastIndexOf(Ce))!==-1&&(de.focus(),(_e=window.find)==null||_e.call(window,Z))},[Z]),Ue=a.useCallback(()=>{const F=W.current;!F||!Z||(F.innerHTML=F.innerHTML.split(Z).join(me),t(F.innerHTML))},[Z,me,t]),ze=a.useCallback(()=>{if(!Z)return;const F=n.split(Z).join(me);t(F);const de=W.current;de&&(de.innerHTML=F)},[Z,me,n,t]),Y=a.useCallback(F=>{const de=W.current;de&&(de.focus(),document.execCommand("insertText",!1,F),t(de.innerHTML),ke(!1))},[t]),ue=a.useCallback(F=>{const de=W.current;de&&(de.focus(),document.execCommand("insertHTML",!1,F),t(de.innerHTML),Ee(!1))},[t]),$e=a.useCallback(F=>{const de=L||h;return F==="fontSize"?e.jsx(P.Ze,{size:"sm",value:"",onChange:xe=>je("fontSize",String(xe)),disabled:de,placeholder:"Size",options:ta.map(xe=>({value:xe.value,label:xe.label})),style:{minWidth:70,maxWidth:80}},F):F==="fontColor"?e.jsx(P.Xe,{value:pe,onChange:xe=>{fe(xe),je("fontColor",xe)},disabled:de,size:"sm",label:"",title:"Text color"},F):F==="bgColor"?e.jsx(P.Xe,{value:ve,onChange:xe=>{ne(xe),je("bgColor",xe)},disabled:de,size:"sm",label:"",title:"Highlight color"},F):e.jsx(P.pn,{size:"sm",variant:F==="markdown"&&H||F==="fullscreen"&&te||F==="source"&&o||F==="findReplace"&&N||F==="emoji"&&ie?"primary":"ghost",onClick:()=>je(F),title:F,disabled:de,children:ea[F]||F},F)},[L,h,je,H,te,pe,ve,o,N,ie]);return T?null:e.jsxs("div",{className:`nice-field nice-field--${$} ${X?"nice-field--error":""} ${J||""}`,style:g,children:[K&&e.jsxs("label",{className:"nice-field__label",htmlFor:I,children:[K,p&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{ref:c,className:`nice-htmleditor${te?" nice-htmleditor--fullscreen":""}`,children:[e.jsxs("div",{className:"nice-htmleditor__toolbar",style:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[d.map($e),z&&z.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(P.pn,{size:"sm",variant:be?"primary":"ghost",onClick:()=>Ee(F=>!F),title:"Insert template",children:"??"}),be&&e.jsx("ul",{style:{position:"absolute",top:"100%",right:0,zIndex:200,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:160,maxHeight:200,overflow:"auto"},children:z.map((F,de)=>e.jsx("li",{style:{padding:"6px 10px",cursor:"pointer",borderRadius:4},onMouseDown:xe=>{xe.preventDefault(),ue(F.html)},children:F.label},de))})]})]}),N&&e.jsxs("div",{className:"nice-htmleditor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)",fontSize:"0.875em"},children:[e.jsx("input",{type:"text",placeholder:"Find...",value:Z,onChange:F=>he(F.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx("input",{type:"text",placeholder:"Replace...",value:me,onChange:F=>ae(F.target.value),style:{flex:1,maxWidth:180,padding:"2px 6px",border:"1px solid var(--border-color, #ccc)",borderRadius:4,background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)"}}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>Fe(1),title:"Find next",children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>Fe(-1),title:"Find previous",children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Ue,disabled:L||h,children:"Replace"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:ze,disabled:L||h,children:"All"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>D(!1),children:"?"})]}),ie&&e.jsx("div",{className:"nice-htmleditor__emoji-picker",style:{padding:8,background:"var(--bg-primary, #fff)",borderBottom:"1px solid var(--border-color, #ddd)",maxHeight:180,overflowY:"auto"},children:na.map(F=>e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7em",fontWeight:600,color:"var(--text-muted, #999)",padding:"4px 0"},children:F.label}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:2},children:F.emojis.map(de=>e.jsx("span",{style:{cursor:"pointer",fontSize:"1.2em",padding:2,borderRadius:4},onClick:()=>Y(de),title:de,children:de},de))})]},F.label))}),e.jsx("input",{ref:x,type:"file",accept:"image/*",style:{display:"none"},onChange:He}),o?e.jsx("textarea",{className:"nice-htmleditor__source",value:s,onChange:F=>u(F.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",whiteSpace:"pre",fontSize:"0.85em",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:L||h}):H?e.jsx("textarea",{className:"nice-htmleditor__markdown",value:j,onChange:F=>l(F.target.value),style:{minHeight:r,width:"100%",fontFamily:"monospace",resize:"vertical",background:"var(--bg-primary, #fff)",color:"var(--text-primary, #1f2937)",border:"none",padding:12,boxSizing:"border-box",outline:"none"},disabled:L||h}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:W,id:I,className:"nice-htmleditor__content",contentEditable:!L&&!h,dangerouslySetInnerHTML:{__html:n},onInput:Oe,onKeyDown:Xe,onPaste:Qe,onDrop:Ke,onDragOver:Ge,style:{minHeight:r},"data-placeholder":i,role:"textbox","aria-multiline":"true",suppressContentEditableWarning:!0}),q&&Ae.length>0&&e.jsx("ul",{className:"nice-htmleditor__mention-list",children:Ae.map((F,de)=>e.jsx("li",{className:`nice-htmleditor__mention-item ${de===R?"nice-htmleditor__mention-item--active":""}`,onMouseDown:xe=>{xe.preventDefault(),Be(F)},children:F.label},F.key))})]}),e.jsxs("div",{className:"nice-htmleditor__statusbar",style:{display:"flex",gap:12,padding:"2px 8px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)"},children:[b>0&&e.jsxs("span",{children:[re," / ",b]}),C&&e.jsxs("span",{children:[ge," words"]}),C&&e.jsxs("span",{children:[re," chars"]}),o&&e.jsx("span",{style:{fontWeight:600},children:"HTML Source"}),H&&e.jsx("span",{style:{fontWeight:600},children:"Markdown"})]})]}),X&&e.jsx("div",{className:"nice-field__error",children:X}),G&&!X&&e.jsx("div",{className:"nice-field__hint",children:G})]})},ra=Object.freeze(Object.defineProperty({__proto__:null,NiceHtmlEditor:jt},Symbol.toStringTag,{value:"Module"})),la=[{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"}],sa=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}];a.forwardRef(function(n,t){var ge,se;const{enableAI:i=!0,aiModel:r,enableImprove:d=!0,enableTranslate:h=!0,enableGenerate:y=!0,toolbar:w,languages:M=la,textStyles:S=sa,onImprove:U,onTranslate:A,onGenerate:b,showAIToolbar:C=!0,value:z,onChange:K,...X}=n,G=a.useRef(null),[p,L]=a.useState(!1),[$,E]=a.useState(!1),[J,g]=a.useState(!1),[k,v]=a.useState(""),[T,I]=a.useState(""),[W,x]=a.useState("professional"),[c,H]=a.useState(""),[_,j]=a.useState(((ge=M[0])==null?void 0:ge.code)||"en"),[l,o]=a.useState(""),[m,s]=a.useState(""),{t:u}=P.ue(),q=P.me(),{improveText:B,translate:V,generateHtml:le,isLoading:R}=P.qd(),O=i&&q.isConfigured,te=a.useCallback(()=>{const N=window.getSelection();return N&&N.toString().trim()?N.toString():""},[]),oe=a.useCallback(N=>{const D=window.getSelection();if(D&&D.rangeCount>0){const Z=D.getRangeAt(0);Z.deleteContents();const he=document.createElement("div");he.innerHTML=N;const me=document.createDocumentFragment();for(;he.firstChild;)me.appendChild(he.firstChild);if(Z.insertNode(me),G.current){const ae=G.current.innerHTML;K(ae)}}},[K]),pe=a.useCallback(async(N="professional")=>{if(!O||!d)return"";const D=te();if(!D)return"";v(D),x(N),L(!0),I("");try{const Z=await B(D,N);return I(Z),U==null||U(D,Z,N),Z}catch{return I(u("htmlEditorAI.improveFailed","Failed to improve text")),""}},[O,d,te,B,U,u]),fe=a.useCallback(async N=>{var Z;if(!O||!h)return"";const D=te();if(!D)return"";v(D),j(N),E(!0),H("");try{const he=((Z=M.find(ae=>ae.code===N))==null?void 0:Z.label)||N,me=await V(D,he);return H(me),A==null||A(D,me,N),me}catch{return H(u("htmlEditorAI.translateFailed","Failed to translate text")),""}},[O,h,te,V,M,A,u]),ve=a.useCallback(async N=>{if(!O||!y||!N.trim())return"";o(N),s("");try{const D=await le(N);return s(D),b==null||b(N,D),D}catch{return s(u("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[O,y,le,b,u]),ne=a.useCallback(()=>{T&&oe(T),L(!1),I("")},[T,oe]),re=a.useCallback(()=>{c&&oe(c),E(!1),H("")},[c,oe]),ce=a.useCallback(()=>{if(m&&G.current){document.execCommand("insertHTML",!1,m);const N=G.current.innerHTML;K(N)}g(!1),s(""),o("")},[m,K]);return a.useImperativeHandle(t,()=>({getEditor:()=>G.current,focus:()=>{var N;return(N=G.current)==null?void 0:N.focus()},getValue:()=>{var N;return((N=G.current)==null?void 0:N.innerHTML)||""},setValue:N=>{G.current&&(G.current.innerHTML=N,K(N))},getSelection:te,insertHtml:N=>{document.execCommand("insertHTML",!1,N),G.current&&K(G.current.innerHTML)},improveSelection:pe,translateSelection:fe,generateHtml:ve})),a.useCallback(N=>{G.current=N},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":n["data-testid"],children:[C&&O&&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"}),R&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:u("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[d&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>pe(),disabled:R,title:u("htmlEditorAI.improveText","Improve selected text"),children:["✨ ",u("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:S.map(({style:N,label:D})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>pe(N),children:D},N))})]}),h&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:R,title:u("htmlEditorAI.translateText","Translate selected text"),children:["🌐 ",u("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:M.map(({code:N,label:D})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>fe(N),children:D},N))})]}),y&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>g(!0),disabled:R,title:u("htmlEditorAI.generateHtml","Generate HTML from description"),children:["⚡ ",u("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(jt,{value:z,onChange:K,toolbar:w,...X})}),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:["✨ ",u("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:S.map(({style:N,label:D})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${W===N?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{x(N),pe(N)},children:D},N))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>L(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:R?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:u("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:u("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:u("htmlEditorAI.improved","Improved")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:T})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ne,disabled:!T||R,children:["✓ ",u("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{L(!1),I("")},children:u("htmlEditorAI.cancel","Cancel")})]})]}),$&&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:["🌐 ",u("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:_,onChange:N=>{j(N.target.value),fe(N.target.value)},className:"nice-html-editor-ai__language-select",children:M.map(({code:N,label:D})=>e.jsx("option",{value:N,children:D},N))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>E(!1),children:"✕"})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:R?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:u("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:u("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:k})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:((se=M.find(N=>N.code===_))==null?void 0:se.label)||_}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:c})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:re,disabled:!c||R,children:["✓ ",u("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{E(!1),H("")},children:u("htmlEditorAI.cancel","Cancel")})]})]}),J&&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:["⚡ ",u("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close",onClick:()=>{g(!1),s(""),o("")},children:"✕"})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:u("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:l,onChange:N=>o(N.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>ve(l),disabled:R||!l.trim(),children:R?u("htmlEditorAI.generating","Generating..."):u("htmlEditorAI.generate","Generate")})]}),m&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:u("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:m}}),e.jsx("h5",{children:u("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:m})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ce,disabled:!m||R,children:["✓ ",u("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{g(!1),s(""),o("")},children:u("htmlEditorAI.cancel","Cancel")})]})]})]})});const rn=a.forwardRef(({length:n=6,value:t="",onChange:i,masked:r=!1,onComplete:d,label:h,helperText:y,error:w,required:M,disabled:S,readOnly:U,size:A="md",name:b,id:C,className:z,style:K,autoFocus:X,labelPlacement:G,errorPlacement:p,labelWidth:L,controlWidth:$,loading:E,cellWidth:J,...g},k)=>{const v=P.nl(C),T=a.useRef([]),I=t.padEnd(n,"").slice(0,n).split(""),W=a.useCallback(j=>{var o;const l=Math.max(0,Math.min(n-1,j));(o=T.current[l])==null||o.focus()},[n]),x=a.useCallback(j=>{const l=j.join("");i==null||i(l),l.length===n&&l.indexOf("")===-1&&/^\d+$/.test(l)&&(d==null||d(l))},[i,d,n]),c=a.useCallback((j,l)=>{const o=l.target.value.replace(/\D/g,"").slice(-1);if(!o)return;const m=[...I];m[j]=o,x(m),W(j+1)},[I,x,W]),H=a.useCallback((j,l)=>{if(l.key==="Backspace"){l.preventDefault();const o=[...I];I[j]?(o[j]="",x(o)):j>0&&(o[j-1]="",x(o),W(j-1))}else l.key==="ArrowLeft"?(l.preventDefault(),W(j-1)):l.key==="ArrowRight"&&(l.preventDefault(),W(j+1))},[I,x,W]),_=a.useCallback(j=>{j.preventDefault();const l=j.clipboardData.getData("text").replace(/\D/g,"").slice(0,n);if(!l)return;const o=l.padEnd(n,"").slice(0,n).split("");for(let m=l.length;m<n;m++)o[m]=I[m]||"";x(o),W(Math.min(l.length,n-1))},[n,I,x,W]);return e.jsxs("div",{className:`nice-field nice-field--${A} nice-field--otp${G?` nice-field--label-${G}`:""}${p==="right"?" nice-field--error-right":""} ${E?"nice-field--loading":""} ${z||""}`,style:{...K,...L!=null&&{"--nice-field-label-width":typeof L=="number"?`${L}px`:L},...$!=null&&{"--nice-field-control-width":typeof $=="number"?`${$}px`:$},...J!=null&&{"--nice-otp-cell-width":typeof J=="number"?`${J}px`:J}},"aria-busy":E||void 0,...g,children:[h&&e.jsx("label",{htmlFor:`${v}-0`,className:`nice-field__label ${M?"nice-field__label--required":""}`,children:h}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:k,className:`nice-otp nice-otp--${A} ${w?"nice-otp--error":""} ${S?"nice-otp--disabled":""}`,onPaste:_,children:[Array.from({length:n},(j,l)=>e.jsx("input",{ref:o=>{T.current[l]=o},id:l===0?`${v}-0`:void 0,className:"nice-otp__digit",type:r?"password":"text",inputMode:"numeric",maxLength:2,value:I[l]||"",disabled:S,readOnly:U,autoFocus:X&&l===0,"aria-invalid":!!w,"aria-label":`${l+1}`,onChange:o=>c(l,o),onKeyDown:o=>H(l,o),onFocus:o=>o.target.select()},l)),b&&e.jsx("input",{type:"hidden",name:b,value:t})]}),p==="right"&&w&&e.jsx("div",{id:`${v}-error`,className:"nice-field__error",role:"alert",children:w}),p==="right"&&!w&&y&&e.jsx("div",{id:`${v}-helper`,className:"nice-field__helper",children:y}),E&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),p!=="right"&&w&&e.jsx("div",{id:`${v}-error`,className:"nice-field__error",role:"alert",children:w}),p!=="right"&&!w&&y&&e.jsx("div",{id:`${v}-helper`,className:"nice-field__helper",children:y})]})});rn.displayName="NiceInputOtp";const oa={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160},st=6,at=135,ln=405,et=ln-at;function vt(n,t,i,r){const d=(r-90)*(Math.PI/180);return{x:n+i*Math.cos(d),y:t+i*Math.sin(d)}}function It(n,t,i,r,d){const h=vt(n,t,i,r),y=vt(n,t,i,d),w=d-r>180?1:0;return`M ${h.x} ${h.y} A ${i} ${i} 0 ${w} 1 ${y.x} ${y.y}`}const sn=a.forwardRef(({value:n=0,onChange:t,min:i=0,max:r=100,step:d=1,showValue:h=!0,valueTemplate:y="{value}",label:w,helperText:M,error:S,required:U,disabled:A,readOnly:b,size:C="md",name:z,id:K,className:X,style:G,labelPlacement:p="top",errorPlacement:L,labelWidth:$,controlWidth:E,loading:J,isLabelCentered:g=!0,...k},v)=>{const T=P.nl(K),I=a.useRef(!1),W=a.useRef(null),x=typeof C=="number"?C:oa[C],c=x/2,H=x/2,_=(x-st*2)/2,j=r>i?(n-i)/(r-i):0,l=at+j*et,o=a.useCallback(B=>{let V=B-at;V<0&&(V+=360),V>et&&(V=V-et<360-V?et:0);const le=Math.max(0,Math.min(1,V/et)),R=i+le*(r-i),O=Math.round(R/d)*d;return Math.max(i,Math.min(r,O))},[i,r,d]),m=a.useCallback(B=>{if(A||b)return;const V=W.current;if(!V)return;const le=V.getBoundingClientRect(),R=B.clientX-le.left-le.width/2,O=B.clientY-le.top-le.height/2;let te=Math.atan2(R,-O)*(180/Math.PI);te<0&&(te+=360);const oe=o(te);t==null||t(oe)},[o,A,b,t]);a.useEffect(()=>{const B=le=>{I.current&&m(le)},V=()=>{I.current=!1};return window.addEventListener("pointermove",B),window.addEventListener("pointerup",V),()=>{window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",V)}},[m]);const s=a.useCallback(B=>{if(A||b)return;let V=n;B.key==="ArrowUp"||B.key==="ArrowRight"?(B.preventDefault(),V=Math.min(r,n+d)):(B.key==="ArrowDown"||B.key==="ArrowLeft")&&(B.preventDefault(),V=Math.max(i,n-d)),V!==n&&(t==null||t(V))},[n,t,i,r,d,A,b]),u=y.replace("{value}",String(n)),q=vt(c,H,_,l);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${L||"bottom"} nice-field--${typeof C=="string"?C:"md"} ${J?"nice-field--loading":""} ${X||""}`,style:{...G,...$!=null&&{"--nice-field-label-width":typeof $=="number"?`${$}px`:$},...E!=null&&{"--nice-field-control-width":typeof E=="number"?`${E}px`:E}},"aria-busy":J||void 0,...k,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${p} ${g?"nice-knob-field--label-centered":""}`,children:[w&&e.jsx("label",{htmlFor:T,className:`nice-field__label ${U?"nice-field__label--required":""}`,children:w}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:B=>{W.current=B,typeof v=="function"?v(B):v&&(v.current=B)},className:`nice-knob nice-knob--${C} ${A?"nice-knob--disabled":""} ${S?"nice-knob--error":""}`,role:"slider",id:T,tabIndex:A?-1:0,"aria-valuenow":n,"aria-valuemin":i,"aria-valuemax":r,"aria-disabled":A,"aria-invalid":!!S,onPointerDown:B=>{A||b||(I.current=!0,m(B))},onKeyDown:s,children:[e.jsxs("svg",{width:x,height:x,viewBox:`0 0 ${x} ${x}`,children:[e.jsx("path",{d:It(c,H,_,at,ln),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:st,strokeLinecap:"round"}),j>0&&e.jsx("path",{d:It(c,H,_,at,l),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:st,strokeLinecap:"round"}),e.jsx("circle",{cx:q.x,cy:q.y,r:st,fill:"var(--nice-primary, #3b82f6)"})]}),h&&e.jsx("span",{className:"nice-knob__value",children:u}),z&&e.jsx("input",{type:"hidden",name:z,value:n}),J&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),S&&e.jsx("div",{className:"nice-field__error",role:"alert",children:S}),!S&&M&&e.jsx("div",{className:"nice-field__helper",children:M})]})});sn.displayName="NiceKnob";const on=a.forwardRef(({value:n="",onChange:t,suggestions:i=[],onSearch:r,trigger:d="@",renderSuggestion:h,placeholder:y,rows:w=3,label:M,helperText:S,error:U,required:A,disabled:b,readOnly:C,size:z="md",name:K,id:X,className:G,style:p,...L},$)=>{const E=P.nl(X),[J,g]=a.useState(!1),[k,v]=a.useState(""),[T,I]=a.useState(0),[W,x]=a.useState({top:0,left:0}),c=a.useRef(null),H=a.useRef(-1),_=i.map(s=>typeof s=="string"?{key:s,label:s}:s).filter(s=>s.label.toLowerCase().includes(k.toLowerCase())),j=a.useCallback(()=>{g(!1),v(""),I(0),H.current=-1},[]),l=a.useCallback(s=>{const u=c.current;if(!u||H.current<0)return;const q=n.slice(0,H.current),B=n.slice(u.selectionStart),V=`${d}${s.label} `,le=q+V+B;t==null||t(le),j(),requestAnimationFrame(()=>{const R=q.length+V.length;u.setSelectionRange(R,R),u.focus()})},[n,t,d,j]),o=a.useCallback(s=>{const u=s.target.value;t==null||t(u);const q=s.target.selectionStart,B=u.slice(0,q),V=B.lastIndexOf(d);if(V>=0){const le=V>0?B[V-1]:" ",R=B.slice(V+d.length);if(/\s/.test(le)&&!/\s/.test(R)){H.current=V;const O=R;v(O),g(!0),I(0),r==null||r(O);const te=s.target,oe=te.getBoundingClientRect(),pe=parseInt(getComputedStyle(te).lineHeight)||20,fe=B.split(`
|
|
11
|
+
`);x({top:oe.top+fe.length*pe+4-te.scrollTop,left:oe.left+8});return}}j()},[t,d,r,j]),m=a.useCallback(s=>{!J||_.length===0||(s.key==="ArrowDown"?(s.preventDefault(),I(u=>(u+1)%_.length)):s.key==="ArrowUp"?(s.preventDefault(),I(u=>(u-1+_.length)%_.length)):s.key==="Enter"?(s.preventDefault(),_[T]&&l(_[T])):s.key==="Escape"&&j())},[J,_,T,l,j]);return a.useEffect(()=>{if(!J)return;const s=u=>{const q=c.current;q&&!q.contains(u.target)&&j()};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[J,j]),e.jsxs("div",{className:`nice-field ${G||""}`,style:p,...L,children:[M&&e.jsx("label",{htmlFor:E,className:`nice-field__label ${A?"nice-field__label--required":""}`,children:M}),e.jsxs("div",{className:`nice-mention nice-mention--${z} ${U?"nice-mention--error":""} ${b?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:s=>{c.current=s,typeof $=="function"?$(s):$&&($.current=s)},id:E,name:K,className:"nice-mention__input",value:n,onChange:o,onKeyDown:m,placeholder:y,rows:w,disabled:b,readOnly:C,"aria-invalid":!!U,"aria-describedby":U?`${E}-error`:S?`${E}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":J}),J&&_.length>0&&e.jsx("ul",{className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:W.top,left:W.left},children:_.map((s,u)=>e.jsx("li",{role:"option","aria-selected":u===T,className:`nice-mention__suggestion ${u===T?"nice-mention__suggestion--active":""}`,onMouseDown:q=>{q.preventDefault(),l(s)},onMouseEnter:()=>I(u),children:h?h(s):e.jsxs(e.Fragment,{children:[s.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:s.icon}),e.jsx("span",{children:s.label})]})},s.key))})]}),U&&e.jsx("div",{id:`${E}-error`,className:"nice-field__error",role:"alert",children:U}),!U&&S&&e.jsx("div",{id:`${E}-helper`,className:"nice-field__helper",children:S})]})});on.displayName="NiceMention";function ca(n){const t=[],i=r=>{for(const d of r)t.push(d),d.children&&i(d.children)};return i(n),t}function cn(n,t){const i=t.toLowerCase();return n.reduce((r,d)=>{const h=d.children?cn(d.children,t):[];return(d.label.toLowerCase().includes(i)||h.length>0)&&r.push({...d,children:h.length>0?h:d.children}),r},[])}const dn=({node:n,level:t,selectedKeys:i,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:y,maxDepth:w})=>{const M=typeof w=="number"?Math.min(10,Math.max(1,w)):1/0,S=!(t+1>=M)&&n.children&&n.children.length>0,U=r.has(n.key),A=i.has(n.key),b=!S,C=!n.disabled&&(!y||b),z=Math.min(t+1,10),K={paddingLeft:t*16+8,"--nice-row-bg":`var(--nice-tree-level-${z}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${z}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${z}-hover-bg, var(--bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${z}-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 ${A?"nice-tree-select__node--selected":""} ${n.disabled?"nice-tree-select__node--disabled":""}`,style:K,"data-nice-depth":z,onClick:()=>C&&h(n.key),role:"treeitem","aria-selected":A,"aria-expanded":S?U:void 0,"aria-disabled":n.disabled,children:[S?e.jsx("button",{type:"button",className:"nice-tree-select__toggle",onClick:X=>{X.stopPropagation(),d(n.key)},"aria-label":"Toggle",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"currentColor",style:{transform:U?"rotate(90deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),(n.icon==null,null),e.jsx("span",{className:"nice-tree-select__node-label",children:n.label})]}),S&&U&&n.children.map(X=>e.jsx(dn,{node:X,level:t+1,selectedKeys:i,expandedKeys:r,onToggleExpand:d,onSelect:h,selectableLeafsOnly:y,maxDepth:w},X.key))]})},un=a.forwardRef(({nodes:n,value:t,onChange:i,multiple:r=!1,searchable:d=!1,placeholder:h,selectableLeafsOnly:y=!1,clearable:w=!1,maxDepth:M,label:S,helperText:U,error:A,required:b,disabled:C,readOnly:z,size:K="md",name:X,id:G,className:p,style:L,controlWidth:$,...E},J)=>{const{t:g}=P.ue(),k=P.nl(G),[v,T]=a.useState(!1),[I,W]=a.useState(""),[x,c]=a.useState(new Set),H=a.useRef(null);P.sl(H,()=>T(!1));const _=a.useMemo(()=>t==null?new Set:new Set(Array.isArray(t)?t:[t]),[t]),j=a.useMemo(()=>I?cn(n,I):n,[n,I]),l=a.useMemo(()=>{const u=ca(n);return Array.from(_).map(q=>{var B;return(B=u.find(V=>V.key===q))==null?void 0:B.label}).filter(Boolean)},[_,n]),o=a.useCallback(u=>{c(q=>{const B=new Set(q);return B.has(u)?B.delete(u):B.add(u),B})},[]),m=a.useCallback(u=>{if(r){const q=new Set(_);q.has(u)?q.delete(u):q.add(u),i==null||i(Array.from(q))}else i==null||i(u),T(!1)},[r,_,i]),s=a.useCallback(u=>{u.stopPropagation(),i==null||i(r?[]:"")},[i,r]);return e.jsxs("div",{className:`nice-field nice-field--${K} ${p||""}`,style:{width:"fit-content",maxWidth:"100%",...L},...E,children:[S&&e.jsx("label",{htmlFor:k,className:`nice-field__label ${b?"nice-field__label--required":""}`,children:S}),e.jsxs("div",{ref:H,className:"nice-tree-select",style:{position:"relative",width:$!=null?typeof $=="number"?`${$}px`:$:240},children:[e.jsxs("div",{ref:J,id:k,className:`nice-input nice-input--${K} ${A?"nice-input--error":""} ${C?"nice-input--disabled":""} ${z?"nice-input--readonly":""}`,role:"combobox","aria-expanded":v,"aria-haspopup":"tree","aria-invalid":!!A,tabIndex:C?-1:0,onClick:()=>!C&&!z&&T(!v),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),!C&&!z&&T(!v))},children:[e.jsx("span",{className:"nice-tree-select__display",children:l.length>0?l.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:h??g("controls.select","Select...")})}),w&&_.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:s,"aria-label":g("controls.clear","Clear"),children:"✕"}),e.jsx("svg",{className:"nice-tree-select__arrow",width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",style:{transform:v?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx("path",{d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"})})]}),v&&e.jsxs("div",{className:"nice-tree-select__dropdown",role:"tree",children:[d&&e.jsx("div",{className:"nice-tree-select__search",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:g("controls.search","Search..."),value:I,onChange:u=>W(u.target.value),autoFocus:!0,onClick:u=>u.stopPropagation()})}),e.jsx("div",{className:"nice-tree-select__list",children:j.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:g("controls.noResults","No results")}):j.map(u=>e.jsx(dn,{node:u,level:0,selectedKeys:_,expandedKeys:x,onToggleExpand:o,onSelect:m,selectableLeafsOnly:y,maxDepth:M},u.key))})]})]}),X&&e.jsx("input",{type:"hidden",name:X,value:Array.isArray(t)?t.join(","):t??""}),A&&e.jsx("div",{id:`${k}-error`,className:"nice-field__error",role:"alert",children:A}),!A&&U&&e.jsx("div",{id:`${k}-helper`,className:"nice-field__helper",children:U})]})});un.displayName="NiceTreeSelect";function qe(n,t){return String(n[t])}const pn=a.forwardRef(({source:n,target:t,onChange:i,keyField:r="id",labelField:d="label",renderItem:h,filterable:y=!1,searchable:w,groupBy:M,sortable:S=!1,bulkActions:U=!0,maxRight:A,sourceHeader:b,targetHeader:C,disabled:z=!1,size:K="md",className:X,style:G,id:p,...L},$)=>{const{t:E}=P.ue(),[J,g]=a.useState(new Set),[k,v]=a.useState(new Set),[T,I]=a.useState(""),[W,x]=a.useState(""),c=a.useCallback((u,q,B)=>{q(V=>{const le=new Set(V);return le.has(B)?le.delete(B):le.add(B),le})},[]),H=a.useCallback(()=>{const u=n.filter(le=>J.has(qe(le,r))),q=n.filter(le=>!J.has(qe(le,r))),B=typeof A=="number"?u.slice(0,Math.max(0,A-t.length)):u,V=u.slice(B.length);i([...q,...V],[...t,...B]),g(new Set)},[n,t,J,r,i,A]),_=a.useCallback(()=>{const u=t.filter(B=>k.has(qe(B,r))),q=t.filter(B=>!k.has(qe(B,r)));i([...n,...u],q),v(new Set)},[n,t,k,r,i]),j=a.useCallback(()=>{if(typeof A=="number"){const u=Math.max(0,A-t.length),q=n.slice(0,u),B=n.slice(u);i(B,[...t,...q])}else i([],[...t,...n]);g(new Set)},[n,t,i,A]),l=a.useCallback(()=>{i([...n,...t],[]),v(new Set)},[n,t,i]),o=(u,q)=>{if(!q)return u;const B=q.toLowerCase();return u.filter(V=>String(V[d]).toLowerCase().includes(B))},m=U===!1?{moveAll:!1,removeAll:!1}:U===!0||U===void 0?{moveAll:!0,removeAll:!0}:{moveAll:U.moveAll??!0,removeAll:U.removeAll??!0},s=(u,q,B,V,le,R,O)=>{const te=o(u,V),oe=w===!0||y&&w===void 0?"both":w??!1,pe=oe==="both"||oe==="left"&&O==="left"||oe==="right"&&O==="right",fe=(()=>{if(!M)return[{label:"",items:te}];const re=new Map;for(const ce of te){const ge=String(M(ce));let se=re.get(ge);se||(se=[],re.set(ge,se)),se.push(ce)}return[...re.entries()].map(([ce,ge])=>({label:ce,items:ge}))})(),ve=(re,ce)=>{re.dataTransfer.setData("text/plain",ce),re.dataTransfer.effectAllowed="move"},ne=(re,ce)=>{re.preventDefault();const ge=re.dataTransfer.getData("text/plain");if(!ge||ge===ce||O!=="right"||!S)return;const se=[...t],N=se.findIndex(he=>qe(he,r)===ge),D=se.findIndex(he=>qe(he,r)===ce);if(N===-1||D===-1)return;const[Z]=se.splice(N,1);se.splice(D,0,Z),i(n,se)};return e.jsxs("div",{className:"nice-picklist__panel",children:[R&&e.jsx("div",{className:"nice-picklist__header",children:R}),pe&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",placeholder:E("controls.search","Search..."),value:V,onChange:re=>le(re.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true",children:[fe.map(re=>e.jsxs(a.Fragment,{children:[re.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:re.label}),re.items.map(ce=>{const ge=qe(ce,r),se=q.has(ge);return e.jsx("div",{className:`nice-picklist__item ${se?"nice-picklist__item--selected":""}`,role:"option","aria-selected":se,draggable:S&&O==="right",onDragStart:S&&O==="right"?N=>ve(N,ge):void 0,onDragOver:S&&O==="right"?N=>N.preventDefault():void 0,onDrop:S&&O==="right"?N=>ne(N,ge):void 0,onClick:()=>!z&&c(q,B,ge),children:h?h(ce,O):String(ce[d])},ge)})]},re.label||"__none__")),te.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:E("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:$,id:p,className:`nice-picklist nice-picklist--${K} ${z?"nice-picklist--disabled":""} ${X||""}`,style:G,...L,children:[s(n,J,g,T,I,b??E("picklist.source","Available"),"left"),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||J.size===0,onClick:H,"aria-label":E("picklist.moveRight","Move right"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})})}),m.moveAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||n.length===0,onClick:j,"aria-label":E("picklist.moveAllRight","Move all right"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M4.293 14.707a1 1 0 010-1.414L7.586 10 4.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"}),e.jsx("path",{d:"M10.293 14.707a1 1 0 010-1.414L13.586 10 10.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"})]})}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||k.size===0,onClick:_,"aria-label":E("picklist.moveLeft","Move left"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})})}),m.removeAll&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:z||t.length===0,onClick:l,"aria-label":E("picklist.moveAllLeft","Move all left"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M15.707 5.293a1 1 0 010 1.414L12.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"}),e.jsx("path",{d:"M9.707 5.293a1 1 0 010 1.414L6.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"})]})})]}),s(t,k,v,W,x,C??E("picklist.target","Selected"),"right")]})});pn.displayName="NicePickList";let tt=null,nt=null;const da="0.45.0",pt=`https://cdn.jsdelivr.net/npm/monaco-editor@${da}/min/vs`,At=15e3;function zt(){var r;const n=window;if((r=n.MonacoEnvironment)!=null&&r.getWorkerUrl)return;const t=`self.MonacoEnvironment={baseUrl:'${pt}/'};importScripts('${pt}/base/worker/workerMain.js');`,i=URL.createObjectURL(new Blob([t],{type:"text/javascript"}));n.MonacoEnvironment={getWorkerUrl:()=>i}}function Ze(n){var i;if(n!=="auto")return n;if(typeof document>"u")return"vs";const t=document.documentElement.dataset.theme;return t==="dark"?"vs-dark":t==="light"?"vs":(i=window.matchMedia)!=null&&i.call(window,"(prefers-color-scheme: dark)").matches?"vs-dark":"vs"}function hn(){return nt?Promise.resolve(nt):tt||(tt=new Promise((n,t)=>{if(window.monaco){zt(),nt=window.monaco,n(nt);return}let i=!1;const r=window.setTimeout(()=>{i||(i=!0,tt=null,t(new Error(`Monaco editor failed to load within ${At}ms`)))},At),d=document.createElement("script");d.src=`${pt}/loader.min.js`,d.async=!0,d.onload=()=>{const h=window.require;h.config({paths:{vs:pt}}),zt(),h(["vs/editor/editor.main"],y=>{i||(i=!0,window.clearTimeout(r),nt=y,n(y))})},d.onerror=()=>{i||(i=!0,window.clearTimeout(r),tt=null,t(new Error("Failed to load Monaco Editor loader script")))},document.head.appendChild(d)}),tt)}const Ct=a.forwardRef(function(n,t){const{value:i,onChange:r,language:d="plaintext",theme:h="auto",options:y={},height:w=400,width:M="100%",markers:S=[],decorations:U=[],completionProvider:A,onMount:b,onCursorPositionChange:C,onSelectionChange:z,onSave:K,loading:X,disabled:G=!1,showToolbar:p=!1,showStatusBar:L=!1,editorSize:$="standard",className:E,"data-testid":J,lsp:g}=n,k=a.useRef(null),v=a.useRef(null),T=a.useRef(null),I=a.useRef([]),W=a.useRef(null),[x,c]=a.useState(!0),[H,_]=a.useState(null),[j,l]=a.useState({lineNumber:1,column:1}),[o,m]=a.useState(""),[s,u]=a.useState(y.wordWrap==="on"),q=a.useMemo(()=>({automaticLayout:!0,readOnly:G||y.readOnly,minimap:{enabled:y.minimap??!0},lineNumbers:y.lineNumbers??"on",wordWrap:y.wordWrap??"off",tabSize:y.tabSize??2,insertSpaces:y.insertSpaces??!0,fontSize:y.fontSize??14,fontFamily:y.fontFamily??"'Fira Code', 'Consolas', 'Monaco', monospace",fontLigatures:y.fontLigatures??!0,cursorStyle:y.cursorStyle??"line",cursorBlinking:y.cursorBlinking??"blink",autoClosingBrackets:y.autoClosingBrackets??"languageDefined",autoClosingQuotes:y.autoClosingQuotes??"languageDefined",formatOnPaste:y.formatOnPaste??!1,formatOnType:y.formatOnType??!1,renderWhitespace:y.renderWhitespace??"selection",renderControlCharacters:y.renderControlCharacters??!1,scrollBeyondLastLine:y.scrollBeyondLastLine??!0,smoothScrolling:y.smoothScrolling??!0,folding:y.folding??!0,showFoldingControls:y.showFoldingControls??"mouseover","bracketPairColorization.enabled":y.bracketPairColorization??!0,guides:y.guides??{bracketPairs:!0,indentation:!0,highlightActiveIndentation:!0},stickyScroll:{enabled:y.stickyScroll??!1},quickSuggestions:y.quickSuggestions??!0,suggestOnTriggerCharacters:y.suggestOnTriggerCharacters??!0,acceptSuggestionOnEnter:y.acceptSuggestionOnEnter??"on",inlayHints:{enabled:y.inlayHints?"on":"off"}}),[y,G]);a.useEffect(()=>{if(!k.current)return;let R=!0;return hn().then(async O=>{if(!R||!k.current)return;T.current=O;const te=O.editor.create(k.current,{value:i,language:d,theme:Ze(h),...q});if(v.current=te,c(!1),te.onDidChangeModelContent(()=>{const oe=te.getValue();r==null||r(oe)}),te.onDidChangeCursorPosition(oe=>{l({lineNumber:oe.position.lineNumber,column:oe.position.column}),C==null||C({lineNumber:oe.position.lineNumber,column:oe.position.column})}),te.onDidChangeCursorSelection(oe=>{var ve;const pe=oe.selection,fe=((ve=te.getModel())==null?void 0:ve.getValueInRange(pe))??"";m(fe),z==null||z({startLineNumber:pe.startLineNumber,startColumn:pe.startColumn,endLineNumber:pe.endLineNumber,endColumn:pe.endColumn})}),te.addCommand(O.KeyMod.CtrlCmd|O.KeyCode.KeyS,()=>{K==null||K(te.getValue())}),g&&typeof window<"u")try{await ht("https://cdn.jsdelivr.net/npm/vscode-ws-jsonrpc@1.0.2/lib/browser/index.min.js"),await ht("https://cdn.jsdelivr.net/npm/monaco-languageclient@0.15.0/lib/monaco-languageclient.min.js");const oe=window,pe=oe.ReconnectingWebSocket,{MonacoLanguageClient:fe,CloseAction:ve,ErrorAction:ne,createConnection:re}=oe.monacoLanguageClient||{};if(fe&&re){const ce=g.url,ge=g.language,se=new pe(ce),N=new oe.VSCodeWebSocketMessageReader(se),D=new oe.VSCodeWebSocketMessageWriter(se),Z=re(N,D),he=new fe({name:"LSP Client",clientOptions:{documentSelector:[ge],initializationOptions:g.initOptions,errorHandler:{error:()=>ne.Continue,closed:()=>ve.Restart}},connectionProvider:{get:()=>Promise.resolve(Z)}});he.start(),v.current.__lspClient=he}}catch(oe){console.warn("LSP bridge failed to load:",oe)}b==null||b(te,O)}).catch(O=>{R&&(_(O.message??"Failed to load editor"),c(!1))}),()=>{var O,te;if(R=!1,(O=v.current)==null||O.dispose(),(te=W.current)==null||te.dispose(),v.current&&v.current.__lspClient)try{v.current.__lspClient.stop()}catch{}}},[g]),a.useEffect(()=>{const R=v.current;if(R&&i!==R.getValue()){const O=R.getPosition();R.setValue(i),O&&R.setPosition(O)}},[i]),a.useEffect(()=>{const R=v.current,O=T.current;if(R&&O){const te=R.getModel();te&&O.editor.setModelLanguage(te,d)}},[d]),a.useEffect(()=>{var pe,fe;const R=T.current;if(!R||(R.editor.setTheme(Ze(h)),h!=="auto"||typeof document>"u"))return;const O=()=>{var ve;(ve=T.current)==null||ve.editor.setTheme(Ze("auto"))},te=new MutationObserver(O);te.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const oe=(pe=window.matchMedia)==null?void 0:pe.call(window,"(prefers-color-scheme: dark)");return(fe=oe==null?void 0:oe.addEventListener)==null||fe.call(oe,"change",O),()=>{var ve;te.disconnect(),(ve=oe==null?void 0:oe.removeEventListener)==null||ve.call(oe,"change",O)}},[h]),a.useEffect(()=>{const R=v.current;R&&R.updateOptions(q)},[q]),a.useEffect(()=>{const R=v.current,O=T.current;if(R&&O){const te=R.getModel();if(te){const oe=S.map(pe=>({startLineNumber:pe.startLineNumber,startColumn:pe.startColumn,endLineNumber:pe.endLineNumber,endColumn:pe.endColumn,message:pe.message,severity:pe.severity}));O.editor.setModelMarkers(te,"owner",oe)}}},[S]),a.useEffect(()=>{const R=v.current;if(R&&U.length>0){const O=U.map(te=>({range:{startLineNumber:te.range.startLineNumber,startColumn:te.range.startColumn,endLineNumber:te.range.endLineNumber,endColumn:te.range.endColumn},options:{className:te.className,glyphMarginClassName:te.glyphMarginClassName,hoverMessage:te.hoverMessage?{value:te.hoverMessage}:void 0,isWholeLine:te.isWholeLine}}));I.current=R.deltaDecorations(I.current,O)}},[U]),a.useEffect(()=>{var te;const R=T.current;if(!R||!A)return;(te=W.current)==null||te.dispose();const O={text:0,method:1,function:2,constructor:3,field:4,variable:5,class:6,interface:7,module:8,property:9,keyword:13,snippet:14,color:15,file:16,reference:17,folder:18};return W.current=R.languages.registerCompletionItemProvider(d,{provideCompletionItems:async(oe,pe)=>({suggestions:(await A(oe,pe)).map(fe=>({label:fe.label,kind:O[fe.kind]??0,insertText:fe.insertText,insertTextRules:fe.insertTextRules==="insertAsSnippet"?4:void 0,documentation:fe.documentation,detail:fe.detail,range:{startLineNumber:pe.lineNumber,startColumn:pe.column,endLineNumber:pe.lineNumber,endColumn:pe.column}}))})}),()=>{var oe;(oe=W.current)==null||oe.dispose()}},[d,A]),a.useImperativeHandle(t,()=>({getEditor:()=>v.current,getMonaco:()=>T.current,focus:()=>{var R;return(R=v.current)==null?void 0:R.focus()},getValue:()=>{var R;return((R=v.current)==null?void 0:R.getValue())??""},setValue:R=>{var O;return(O=v.current)==null?void 0:O.setValue(R)},getSelection:()=>{var te;const R=v.current;if(!R)return"";const O=R.getSelection();return O?((te=R.getModel())==null?void 0:te.getValueInRange(O))??"":""},insertText:R=>{const O=v.current;if(!O)return;const te=O.getSelection();te&&O.executeEdits("",[{range:te,text:R}])},formatDocument:()=>{var R,O;(O=(R=v.current)==null?void 0:R.getAction("editor.action.formatDocument"))==null||O.run()},goToLine:(R,O=1)=>{const te=v.current;te&&(te.setPosition({lineNumber:R,column:O}),te.revealLineInCenter(R),te.focus())},findReplace:()=>{var R,O;(O=(R=v.current)==null?void 0:R.getAction("editor.action.startFindReplaceAction"))==null||O.run()},undo:()=>{var R;(R=v.current)==null||R.trigger("keyboard","undo",null)},redo:()=>{var R;(R=v.current)==null||R.trigger("keyboard","redo",null)},getCursorPosition:()=>{var O;const R=(O=v.current)==null?void 0:O.getPosition();return{lineNumber:(R==null?void 0:R.lineNumber)??1,column:(R==null?void 0:R.column)??1}},setMarkers:R=>{const O=v.current,te=T.current;if(O&&te){const oe=O.getModel();if(oe){const pe=R.map(fe=>({startLineNumber:fe.startLineNumber,startColumn:fe.startColumn,endLineNumber:fe.endLineNumber,endColumn:fe.endColumn,message:fe.message,severity:fe.severity}));te.editor.setModelMarkers(oe,"owner",pe)}}}}),[]);const B=a.useMemo(()=>({format:()=>{var R,O;return(O=(R=v.current)==null?void 0:R.getAction("editor.action.formatDocument"))==null?void 0:O.run()},undo:()=>{var R;return(R=v.current)==null?void 0:R.trigger("keyboard","undo",null)},redo:()=>{var R;return(R=v.current)==null?void 0:R.trigger("keyboard","redo",null)},find:()=>{var R,O;return(O=(R=v.current)==null?void 0:R.getAction("editor.action.startFindReplaceAction"))==null?void 0:O.run()},toggleWordWrap:()=>{var O;const R=!s;u(R),(O=v.current)==null||O.updateOptions({wordWrap:R?"on":"off"})},toggleMinimap:()=>{var O,te,oe,pe,fe,ve;const R=(fe=(O=v.current)==null?void 0:O.getOption)==null?void 0:fe.call(O,(pe=(oe=(te=T.current)==null?void 0:te.editor)==null?void 0:oe.EditorOption)==null?void 0:pe.minimap);(ve=v.current)==null||ve.updateOptions({minimap:{enabled:!(R!=null&&R.enabled)}})},foldAll:()=>{var R,O;return(O=(R=v.current)==null?void 0:R.getAction("editor.foldAll"))==null?void 0:O.run()},unfoldAll:()=>{var R,O;return(O=(R=v.current)==null?void 0:R.getAction("editor.unfoldAll"))==null?void 0:O.run()}}),[s]),V=i.split(`
|
|
12
|
+
`).length,le=i.length;return e.jsxs("div",{className:`nice-code-editor-wrap nice-editor--${$} ${E??""}`,style:{height:w,width:M,display:"flex",flexDirection:"column",position:"relative"},"data-testid":J,children:[H&&e.jsxs("div",{className:"nice-code-editor__error",style:{position:"absolute",inset:0,zIndex:2,background:"var(--nice-bg-primary, #fff)"},children:[e.jsxs("span",{children:["⚠️ ",H]}),e.jsx("textarea",{value:i,onChange:R=>r==null?void 0:r(R.target.value),readOnly:G||y.readOnly,style:{width:"100%",height:"100%",fontFamily:"monospace"}})]}),x&&!H&&e.jsx("div",{className:"nice-code-editor__loader-overlay",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)"},children:X??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading editor..."})}),p&&e.jsxs("div",{className:"nice-code-editor__toolbar",children:[e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.undo,title:"Undo (Ctrl+Z)",children:"↶"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.redo,title:"Redo (Ctrl+Y)",children:"↷"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.format,title:"Format (Shift+Alt+F)",children:"⎘"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.find,title:"Find & Replace (Ctrl+H)",children:"🔍"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:`nice-code-editor__toolbar-btn${s?" nice-code-editor__toolbar-btn--active":""}`,onClick:B.toggleWordWrap,title:"Toggle Word Wrap",children:"↩"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.toggleMinimap,title:"Toggle Minimap",children:"▥"}),e.jsx("span",{className:"nice-code-editor__toolbar-sep"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.foldAll,title:"Fold All",children:"⊟"}),e.jsx("button",{className:"nice-code-editor__toolbar-btn",onClick:B.unfoldAll,title:"Unfold All",children:"⊞"})]}),e.jsx("div",{ref:k,className:"nice-code-editor",style:{flex:1,minHeight:0}}),L&&e.jsxs("div",{className:"nice-code-editor__statusbar",children:[e.jsxs("span",{children:["Ln ",j.lineNumber,", Col ",j.column]}),o.length>0&&e.jsxs("span",{children:["(",o.length," selected)"]}),e.jsx("span",{className:"nice-code-editor__statusbar-spacer"}),e.jsxs("span",{children:[V," lines · ",le," chars"]}),e.jsx("span",{className:"nice-code-editor__statusbar-lang",children:d}),S.length>0&&e.jsxs("span",{className:"nice-code-editor__statusbar-markers",children:["⚠ ",S.length]})]})]})});function mn(n){const{original:t,modified:i,language:r="plaintext",theme:d="auto",height:h=400,width:y="100%",inline:w=!1,renderSideBySide:M=!0,originalEditable:S=!1,modifiedEditable:U=!1,onOriginalChange:A,onModifiedChange:b,loading:C,className:z,"data-testid":K}=n,X=a.useRef(null),G=a.useRef(null),p=a.useRef(null),[L,$]=a.useState(!0),[E,J]=a.useState(null);return a.useEffect(()=>{if(!X.current)return;let g=!0;return hn().then(k=>{if(!g||!X.current)return;p.current=k;const v=k.editor.createModel(t,r),T=k.editor.createModel(i,r),I=k.editor.createDiffEditor(X.current,{automaticLayout:!0,theme:Ze(d),renderSideBySide:!w&&M,originalEditable:S,readOnly:!U});I.setModel({original:v,modified:T}),G.current=I,$(!1),S&&v.onDidChangeContent(()=>{A==null||A(v.getValue())}),U&&T.onDidChangeContent(()=>{b==null||b(T.getValue())})}).catch(k=>{g&&(J(k.message??"Failed to load diff editor"),$(!1))}),()=>{var k;g=!1,(k=G.current)==null||k.dispose()}},[]),a.useEffect(()=>{const g=G.current;if(!g)return;const k=g.getModel();k&&(k.original.getValue()!==t&&k.original.setValue(t),k.modified.getValue()!==i&&k.modified.setValue(i))},[t,i]),a.useEffect(()=>{var I,W;const g=p.current;if(!g||(g.editor.setTheme(Ze(d)),d!=="auto"||typeof document>"u"))return;const k=()=>{var x;(x=p.current)==null||x.editor.setTheme(Ze("auto"))},v=new MutationObserver(k);v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const T=(I=window.matchMedia)==null?void 0:I.call(window,"(prefers-color-scheme: dark)");return(W=T==null?void 0:T.addEventListener)==null||W.call(T,"change",k),()=>{var x;v.disconnect(),(x=T==null?void 0:T.removeEventListener)==null||x.call(T,"change",k)}},[d,L]),E?e.jsx("div",{className:`nice-code-diff-editor nice-code-diff-editor--error ${z??""}`,style:{height:h,width:y},"data-testid":K,children:e.jsx("div",{className:"nice-code-editor__error",children:e.jsxs("span",{children:["⚠️ ",E]})})}):e.jsxs("div",{className:`nice-code-diff-editor ${z??""}`,style:{height:h,width:y,position:"relative"},"data-testid":K,children:[e.jsx("div",{ref:X,style:{position:"absolute",inset:0}}),L&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-primary, #fff)",zIndex:2},children:C??e.jsx("div",{className:"nice-code-editor__loader",children:"Loading diff editor..."})})]})}const ua="1.29.0",Pt=`https://cdn.jsdelivr.net/npm/prismjs@${ua}`;let gt=null;const yt={javascript:"javascript",typescript:"typescript",json:"json",html:"markup",css:"css",scss:"scss",less:"less",markdown:"markdown",xml:"markup",yaml:"yaml",sql:"sql",python:"python",csharp:"csharp",java:"java",cpp:"cpp",c:"c",go:"go",rust:"rust",php:"php",ruby:"ruby",shell:"bash",powershell:"powershell",plaintext:"plain"};function ht(n){return new Promise((t,i)=>{if(document.querySelector(`script[data-prism-src="${n}"]`)){t();return}const r=document.createElement("script");r.src=n,r.async=!0,r.dataset.prismSrc=n,r.onload=()=>t(),r.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(r)})}function pa(n){if(typeof window>"u")return Promise.resolve(null);const t=window,i=yt[n]??"plain",r=async()=>{var d,h;if(i!=="plain"&&!((h=(d=t.Prism)==null?void 0:d.languages)!=null&&h[i]))try{await ht(`${Pt}/components/prism-${i}.min.js`)}catch{}};return t.Prism?r().then(()=>t.Prism):(gt||(gt=(async()=>(window.Prism={manual:!0},await ht(`${Pt}/prism.min.js`),window.Prism))()),gt.then(async()=>(await r(),window.Prism)))}function ft(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function gn(n){const{value:t,onChange:i,language:r="plaintext",height:d=300,width:h="100%",readOnly:y=!1,tabSize:w=2,lineNumbers:M=!0,placeholder:S,theme:U="auto",className:A,"data-testid":b}=n,C=a.useRef(null),z=a.useRef(null),[K,X]=a.useState(()=>ft(t)),[G,p]=a.useState("light");a.useEffect(()=>{var I,W;const g=()=>{var c;if(U!=="auto")return U;if(typeof document>"u")return"light";const x=document.documentElement.dataset.theme;return x==="dark"?"dark":x==="light"?"light":(c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"};if(p(g()),U!=="auto"||typeof document>"u")return;const k=()=>p(g()),v=new MutationObserver(k);v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","class"]});const T=(I=window.matchMedia)==null?void 0:I.call(window,"(prefers-color-scheme: dark)");return(W=T==null?void 0:T.addEventListener)==null||W.call(T,"change",k),()=>{var x;v.disconnect(),(x=T==null?void 0:T.removeEventListener)==null||x.call(T,"change",k)}},[U]),a.useEffect(()=>{let g=!0;return pa(r).then(k=>{var T;if(!g)return;const v=yt[r]??"plain";if((T=k==null?void 0:k.languages)!=null&&T[v])try{const I=k.highlight(t,k.languages[v],v);X(I);return}catch{}X(ft(t))}).catch(()=>{g&&X(ft(t))}),()=>{g=!1}},[t,r]);const L=a.useCallback(()=>{!z.current||!C.current||(z.current.scrollTop=C.current.scrollTop,z.current.scrollLeft=C.current.scrollLeft)},[]),$=a.useCallback(g=>{var k;if(g.key==="Tab"){g.preventDefault();const v=g.currentTarget,T=v.selectionStart,I=v.selectionEnd,W=" ".repeat(w);if(g.shiftKey){const x=t.substring(0,T).lastIndexOf(`
|
|
13
|
+
`)+1;if((((k=t.substring(x,T).match(/^(\s*)/))==null?void 0:k[1])??"").length>=w){const c=t.substring(0,x)+t.substring(x+w);i==null||i(c),setTimeout(()=>{v.selectionStart=v.selectionEnd=T-w},0)}}else{const x=t.substring(0,T)+W+t.substring(I);i==null||i(x),setTimeout(()=>{v.selectionStart=v.selectionEnd=T+w},0)}}},[t,i,w]),E=t.split(`
|
|
14
|
+
`).length,J=yt[r]??"plain";return e.jsxs("div",{className:`nice-simple-code-editor nice-simple-code-editor--${G} ${A??""}`,style:{height:d,width:h},"data-testid":b,"data-language":r,"data-theme":G,children:[M&&e.jsx("div",{className:"nice-simple-code-editor__line-numbers",children:Array.from({length:E},(g,k)=>e.jsx("div",{className:"nice-simple-code-editor__line-number",children:k+1},k))}),e.jsxs("div",{className:"nice-simple-code-editor__editor-area",children:[e.jsx("pre",{ref:z,"aria-hidden":"true",className:`nice-simple-code-editor__highlight language-${J}`,children:e.jsx("code",{className:`language-${J}`,dangerouslySetInnerHTML:{__html:K+(t.endsWith(`
|
|
15
|
+
`)?`
|
|
16
|
+
`:"")}})}),e.jsx("textarea",{ref:C,className:"nice-simple-code-editor__textarea",value:t,onChange:g=>i==null?void 0:i(g.target.value),onKeyDown:$,onScroll:L,readOnly:y,placeholder:S,spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"})]})]})}const Ht="nice-code-editor-styles";if(typeof document<"u"&&!document.getElementById(Ht)){const n=document.createElement("style");n.id=Ht,n.textContent=`
|
|
17
|
+
.nice-code-editor,
|
|
18
|
+
.nice-code-diff-editor {
|
|
19
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
20
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nice-code-editor--loading,
|
|
25
|
+
.nice-code-editor--error,
|
|
26
|
+
.nice-code-diff-editor--loading {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nice-code-editor__loader {
|
|
34
|
+
color: var(--nice-text-secondary, #666);
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nice-code-editor__error {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
padding: var(--nice-space-2, 8px);
|
|
44
|
+
gap: var(--nice-space-2, 8px);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.nice-code-editor__error span {
|
|
48
|
+
color: var(--nice-error, #d32f2f);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Simple code editor */
|
|
52
|
+
.nice-simple-code-editor {
|
|
53
|
+
display: flex;
|
|
54
|
+
border: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
55
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
background: var(--bg-primary, var(--nice-bg-surface, #fff));
|
|
61
|
+
color: var(--text-primary, var(--nice-text-primary, #333));
|
|
62
|
+
}
|
|
63
|
+
.nice-simple-code-editor--dark {
|
|
64
|
+
background: var(--nice-bg, #1e1e1e);
|
|
65
|
+
color: var(--nice-text, #d4d4d4);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nice-simple-code-editor__line-numbers {
|
|
69
|
+
padding: var(--nice-space-2, 8px) 0;
|
|
70
|
+
background: var(--bg-secondary, var(--nice-bg-muted, #f5f5f5));
|
|
71
|
+
border-right: 1px solid var(--border-color, var(--nice-border, #e0e0e0));
|
|
72
|
+
user-select: none;
|
|
73
|
+
text-align: right;
|
|
74
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__line-numbers {
|
|
78
|
+
background: var(--nice-bg-secondary, #252526);
|
|
79
|
+
border-right-color: var(--nice-border, #3c3c3c);
|
|
80
|
+
color: var(--nice-text-muted, #858585);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.nice-simple-code-editor__line-number {
|
|
84
|
+
padding: 0 var(--nice-space-3, 12px);
|
|
85
|
+
min-width: 40px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.nice-simple-code-editor__editor-area {
|
|
89
|
+
position: relative;
|
|
90
|
+
flex: 1;
|
|
91
|
+
overflow: hidden;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.nice-simple-code-editor__highlight,
|
|
95
|
+
.nice-simple-code-editor__textarea {
|
|
96
|
+
position: absolute;
|
|
97
|
+
inset: 0;
|
|
98
|
+
margin: 0;
|
|
99
|
+
padding: var(--nice-space-2, 8px) var(--nice-space-3, 12px);
|
|
100
|
+
border: 0;
|
|
101
|
+
font: inherit;
|
|
102
|
+
line-height: inherit;
|
|
103
|
+
white-space: pre;
|
|
104
|
+
overflow: auto;
|
|
105
|
+
tab-size: 2;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-simple-code-editor__highlight {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
background: transparent;
|
|
111
|
+
color: inherit;
|
|
112
|
+
}
|
|
113
|
+
.nice-simple-code-editor__highlight code {
|
|
114
|
+
font: inherit;
|
|
115
|
+
background: transparent;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.nice-simple-code-editor__textarea {
|
|
119
|
+
background: transparent;
|
|
120
|
+
color: transparent;
|
|
121
|
+
caret-color: var(--text-primary, var(--nice-text-primary, #333));
|
|
122
|
+
resize: none;
|
|
123
|
+
outline: none;
|
|
124
|
+
-webkit-text-fill-color: transparent;
|
|
125
|
+
}
|
|
126
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea {
|
|
127
|
+
caret-color: var(--nice-text, #d4d4d4);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.nice-simple-code-editor__textarea::placeholder {
|
|
131
|
+
color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
132
|
+
-webkit-text-fill-color: var(--text-secondary, var(--nice-text-secondary, #999));
|
|
133
|
+
}
|
|
134
|
+
.nice-simple-code-editor--dark .nice-simple-code-editor__textarea::placeholder {
|
|
135
|
+
color: var(--nice-text-muted, #858585);
|
|
136
|
+
-webkit-text-fill-color: var(--nice-text-muted, #858585);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Prism token colors — light */
|
|
140
|
+
.nice-simple-code-editor .token.comment,
|
|
141
|
+
.nice-simple-code-editor .token.prolog,
|
|
142
|
+
.nice-simple-code-editor .token.doctype,
|
|
143
|
+
.nice-simple-code-editor .token.cdata { color: #6a737d; font-style: italic; }
|
|
144
|
+
.nice-simple-code-editor .token.punctuation { color: #586069; }
|
|
145
|
+
.nice-simple-code-editor .token.property,
|
|
146
|
+
.nice-simple-code-editor .token.tag,
|
|
147
|
+
.nice-simple-code-editor .token.boolean,
|
|
148
|
+
.nice-simple-code-editor .token.number,
|
|
149
|
+
.nice-simple-code-editor .token.constant,
|
|
150
|
+
.nice-simple-code-editor .token.symbol,
|
|
151
|
+
.nice-simple-code-editor .token.deleted { color: #005cc5; }
|
|
152
|
+
.nice-simple-code-editor .token.selector,
|
|
153
|
+
.nice-simple-code-editor .token.attr-name,
|
|
154
|
+
.nice-simple-code-editor .token.string,
|
|
155
|
+
.nice-simple-code-editor .token.char,
|
|
156
|
+
.nice-simple-code-editor .token.builtin,
|
|
157
|
+
.nice-simple-code-editor .token.inserted { color: #032f62; }
|
|
158
|
+
.nice-simple-code-editor .token.operator,
|
|
159
|
+
.nice-simple-code-editor .token.entity,
|
|
160
|
+
.nice-simple-code-editor .token.url,
|
|
161
|
+
.nice-simple-code-editor .token.variable { color: var(--nice-danger, #d73a49); }
|
|
162
|
+
.nice-simple-code-editor .token.atrule,
|
|
163
|
+
.nice-simple-code-editor .token.attr-value,
|
|
164
|
+
.nice-simple-code-editor .token.keyword { color: var(--nice-danger, #d73a49); font-weight: 600; }
|
|
165
|
+
.nice-simple-code-editor .token.function,
|
|
166
|
+
.nice-simple-code-editor .token.class-name { color: #6f42c1; }
|
|
167
|
+
.nice-simple-code-editor .token.regex,
|
|
168
|
+
.nice-simple-code-editor .token.important { color: #e36209; }
|
|
169
|
+
|
|
170
|
+
/* Prism token colors — dark */
|
|
171
|
+
.nice-simple-code-editor--dark .token.comment,
|
|
172
|
+
.nice-simple-code-editor--dark .token.prolog,
|
|
173
|
+
.nice-simple-code-editor--dark .token.doctype,
|
|
174
|
+
.nice-simple-code-editor--dark .token.cdata { color: var(--nice-success, #6a9955); font-style: italic; }
|
|
175
|
+
.nice-simple-code-editor--dark .token.punctuation { color: var(--nice-text, #d4d4d4); }
|
|
176
|
+
.nice-simple-code-editor--dark .token.property,
|
|
177
|
+
.nice-simple-code-editor--dark .token.tag,
|
|
178
|
+
.nice-simple-code-editor--dark .token.boolean,
|
|
179
|
+
.nice-simple-code-editor--dark .token.number,
|
|
180
|
+
.nice-simple-code-editor--dark .token.constant,
|
|
181
|
+
.nice-simple-code-editor--dark .token.symbol,
|
|
182
|
+
.nice-simple-code-editor--dark .token.deleted { color: var(--nice-success-light, #b5cea8); }
|
|
183
|
+
.nice-simple-code-editor--dark .token.selector,
|
|
184
|
+
.nice-simple-code-editor--dark .token.attr-name,
|
|
185
|
+
.nice-simple-code-editor--dark .token.string,
|
|
186
|
+
.nice-simple-code-editor--dark .token.char,
|
|
187
|
+
.nice-simple-code-editor--dark .token.builtin,
|
|
188
|
+
.nice-simple-code-editor--dark .token.inserted { color: var(--nice-warning, #ce9178); }
|
|
189
|
+
.nice-simple-code-editor--dark .token.operator,
|
|
190
|
+
.nice-simple-code-editor--dark .token.entity,
|
|
191
|
+
.nice-simple-code-editor--dark .token.url,
|
|
192
|
+
.nice-simple-code-editor--dark .token.variable { color: var(--nice-primary, #569cd6); }
|
|
193
|
+
.nice-simple-code-editor--dark .token.atrule,
|
|
194
|
+
.nice-simple-code-editor--dark .token.attr-value,
|
|
195
|
+
.nice-simple-code-editor--dark .token.keyword { color: #c586c0; font-weight: 600; }
|
|
196
|
+
.nice-simple-code-editor--dark .token.function,
|
|
197
|
+
.nice-simple-code-editor--dark .token.class-name { color: #dcdcaa; }
|
|
198
|
+
.nice-simple-code-editor--dark .token.regex,
|
|
199
|
+
.nice-simple-code-editor--dark .token.important { color: #d7ba7d; }
|
|
200
|
+
|
|
201
|
+
/* Toolbar */
|
|
202
|
+
.nice-code-editor-wrap {
|
|
203
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
204
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
205
|
+
overflow: hidden;
|
|
206
|
+
}
|
|
207
|
+
.nice-code-editor-wrap .nice-code-editor {
|
|
208
|
+
border: none;
|
|
209
|
+
border-radius: 0;
|
|
210
|
+
}
|
|
211
|
+
.nice-code-editor__toolbar {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
gap: var(--nice-space-0-5, 2px);
|
|
215
|
+
padding: var(--nice-space-0-75, 3px) var(--nice-space-1-5, 6px);
|
|
216
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
217
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
218
|
+
}
|
|
219
|
+
.nice-code-editor__toolbar-btn {
|
|
220
|
+
display: inline-flex;
|
|
221
|
+
align-items: center;
|
|
222
|
+
justify-content: center;
|
|
223
|
+
width: 26px;
|
|
224
|
+
height: 26px;
|
|
225
|
+
border: none;
|
|
226
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
227
|
+
background: transparent;
|
|
228
|
+
color: var(--nice-text-secondary, #666);
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
font-size: 14px;
|
|
231
|
+
transition: background 0.15s, color 0.15s;
|
|
232
|
+
}
|
|
233
|
+
.nice-code-editor__toolbar-btn:hover {
|
|
234
|
+
background: var(--nice-hover, #e0e0e0);
|
|
235
|
+
color: var(--nice-text-primary, #333);
|
|
236
|
+
}
|
|
237
|
+
.nice-code-editor__toolbar-btn--active {
|
|
238
|
+
background: var(--nice-accent, #1976d2);
|
|
239
|
+
color: var(--nice-bg, #FFF);
|
|
240
|
+
}
|
|
241
|
+
.nice-code-editor__toolbar-sep {
|
|
242
|
+
width: 1px;
|
|
243
|
+
height: 18px;
|
|
244
|
+
background: var(--nice-border, #e0e0e0);
|
|
245
|
+
margin: 0 var(--nice-space-1, 4px);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Status bar */
|
|
249
|
+
.nice-code-editor__statusbar {
|
|
250
|
+
display: flex;
|
|
251
|
+
align-items: center;
|
|
252
|
+
gap: var(--nice-space-3, 12px);
|
|
253
|
+
padding: var(--nice-space-0-5, 2px) var(--nice-space-2-5, 10px);
|
|
254
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
255
|
+
border-top: 1px solid var(--nice-border, #e0e0e0);
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
color: var(--nice-text-secondary, #666);
|
|
258
|
+
user-select: none;
|
|
259
|
+
}
|
|
260
|
+
.nice-code-editor__statusbar-spacer { flex: 1; }
|
|
261
|
+
.nice-code-editor__statusbar-lang {
|
|
262
|
+
text-transform: uppercase;
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
font-size: 11px;
|
|
265
|
+
}
|
|
266
|
+
.nice-code-editor__statusbar-markers {
|
|
267
|
+
color: var(--nice-warning, #f39c12);
|
|
268
|
+
font-weight: 600;
|
|
269
|
+
}
|
|
270
|
+
`,document.head.appendChild(n)}const ha=Object.freeze(Object.defineProperty({__proto__:null,NiceCodeDiffEditor:mn,NiceCodeEditor:Ct,NiceSimpleCodeEditor:gn},Symbol.toStringTag,{value:"Module"}));a.forwardRef(function(n,t){const{enableAI:i=!0,aiModel:r,enableInlineCompletion:d=!0,completionDelay:h=500,enableExplain:y=!0,enableRefactor:w=!0,enableGenerate:M=!0,systemPrompt:S,onExplain:U,onRefactor:A,showAIToolbar:b=!0,aiShortcutKey:C="Ctrl",language:z="plaintext",value:K,onChange:X,...G}=n,p=a.useRef(null),[L,$]=a.useState(null),[E,J]=a.useState(!1),[g,k]=a.useState(""),[v,T]=a.useState(!1),[I,W]=a.useState(""),[x,c]=a.useState(""),[H,_]=a.useState(""),j=a.useRef(),{t:l}=P.ue(),o=P.me(),{complete:m,explain:s,refactor:u,generateFromComment:q,isLoading:B}=P.Id({language:z,model:r}),V=i&&o.isConfigured,le=a.useCallback(async()=>{if(!V||!d||!p.current||!p.current.getEditor())return;const ne=p.current.getCursorPosition(),re=p.current.getValue().split(`
|
|
271
|
+
`),ce=re.slice(0,ne.lineNumber-1),ge=re[ne.lineNumber-1]||"",se=[...ce,ge.slice(0,ne.column-1)].join(`
|
|
272
|
+
`),N=[ge.slice(ne.column-1),...re.slice(ne.lineNumber)].join(`
|
|
273
|
+
`);try{const D=await m(se,N);D&&$({lineNumber:ne.lineNumber,column:ne.column,text:D})}catch{}},[V,d,m]),R=a.useCallback(async()=>{if(!V||!y||!p.current)return"";const ne=p.current.getSelection();if(!ne)return"";_(ne),J(!0),k("");try{const re=await s(ne);return k(re),U==null||U(ne,re),re}catch{return k(l("codeEditorAI.explanationFailed","Failed to explain code")),""}},[V,y,s,U,l]),O=a.useCallback(async ne=>{if(!V||!w||!p.current)return"";const re=p.current.getSelection();if(!re)return"";try{const ce=await u(re,ne);return c(ce),A==null||A(re,ce),ce}catch{return""}},[V,w,u,A]),te=a.useCallback(async()=>{var ge;if(!V||!M||!p.current)return;const ne=p.current.getCursorPosition(),re=p.current.getValue().split(`
|
|
274
|
+
`);let ce="";for(let se=ne.lineNumber-1;se>=0&&se>=ne.lineNumber-3;se--){const N=((ge=re[se])==null?void 0:ge.trim())||"";if(N.startsWith("//")||N.startsWith("#")||N.startsWith("/*")||N.startsWith("*")){ce=N.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ce)try{const se=await q(ce);se&&p.current&&p.current.insertText(`
|
|
275
|
+
`+se)}catch{}},[V,M,q]),oe=a.useCallback(()=>{!L||!p.current||(p.current.insertText(L.text),$(null))},[L]),pe=a.useCallback(()=>{$(null)},[]),fe=a.useCallback(ne=>{var re;(re=n.onCursorPositionChange)==null||re.call(n,ne),!(!V||!d)&&(j.current&&clearTimeout(j.current),$(null),j.current=setTimeout(()=>{le()},h))},[n.onCursorPositionChange,V,d,h,le]);a.useEffect(()=>{var re;if(!((re=p.current)!=null&&re.getEditor())||!V)return;const ne=ce=>{var ge;if(C==="Ctrl"&&ce.ctrlKey||C==="Alt"&&ce.altKey||C==="Meta"&&ce.metaKey){if(ce.key===" "&&d&&(ce.preventDefault(),le()),ce.key==="e"&&y&&(ce.preventDefault(),R()),ce.key==="r"&&w){ce.preventDefault();const se=(ge=p.current)==null?void 0:ge.getSelection();se&&(_(se),T(!0))}ce.key==="g"&&M&&(ce.preventDefault(),te())}ce.key==="Tab"&&L&&(ce.preventDefault(),oe()),ce.key==="Escape"&&L&&pe()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[V,C,d,y,w,M,le,R,te,L,oe,pe]),a.useEffect(()=>()=>{j.current&&clearTimeout(j.current)},[]);const ve=a.useCallback(()=>{if(!x||!p.current)return;const ne=p.current.getEditor();if(ne!=null&&ne.executeEdits&&(ne!=null&&ne.getSelection)){const re=ne.getSelection();ne.executeEdits("ai-refactor",[{range:re,text:x}])}T(!1),c(""),W("")},[x]);return a.useImperativeHandle(t,()=>({...p.current,getEditor:()=>{var ne;return(ne=p.current)==null?void 0:ne.getEditor()},getMonaco:()=>{var ne;return(ne=p.current)==null?void 0:ne.getMonaco()},focus:()=>{var ne;return(ne=p.current)==null?void 0:ne.focus()},getValue:()=>{var ne;return((ne=p.current)==null?void 0:ne.getValue())||""},setValue:ne=>{var re;return(re=p.current)==null?void 0:re.setValue(ne)},getSelection:()=>{var ne;return((ne=p.current)==null?void 0:ne.getSelection())||""},insertText:ne=>{var re;return(re=p.current)==null?void 0:re.insertText(ne)},formatDocument:()=>{var ne;return(ne=p.current)==null?void 0:ne.formatDocument()},goToLine:(ne,re)=>{var ce;return(ce=p.current)==null?void 0:ce.goToLine(ne,re)},findReplace:()=>{var ne;return(ne=p.current)==null?void 0:ne.findReplace()},undo:()=>{var ne;return(ne=p.current)==null?void 0:ne.undo()},redo:()=>{var ne;return(ne=p.current)==null?void 0:ne.redo()},getCursorPosition:()=>{var ne;return((ne=p.current)==null?void 0:ne.getCursorPosition())||{lineNumber:1,column:1}},setMarkers:ne=>{var re;return(re=p.current)==null?void 0:re.setMarkers(ne)},triggerCompletion:le,explainSelection:R,refactorSelection:O,generateFromComment:te,acceptCompletion:oe,dismissCompletion:pe})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":n["data-testid"],children:[b&&V&&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"}),B&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:l("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[d&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>le(),disabled:B,title:`${l("codeEditorAI.complete","Complete")} (${C}+Space)`,children:["💡 ",l("codeEditorAI.complete","Complete")]}),y&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>R(),disabled:B,title:`${l("codeEditorAI.explain","Explain")} (${C}+E)`,children:["📖 ",l("codeEditorAI.explain","Explain")]}),w&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{var re;const ne=(re=p.current)==null?void 0:re.getSelection();ne&&(_(ne),T(!0))},disabled:B,title:`${l("codeEditorAI.refactor","Refactor")} (${C}+R)`,children:["🔧 ",l("codeEditorAI.refactor","Refactor")]}),M&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>te(),disabled:B,title:`${l("codeEditorAI.generate","Generate")} (${C}+G)`,children:["⚡ ",l("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Ct,{ref:p,value:K,onChange:X,language:z,onCursorPositionChange:fe,...G}),L&&e.jsxs("div",{className:"nice-code-editor-ai__ghost-text",style:{top:`calc(${(L.lineNumber-1)*19}px + 4px)`,left:`calc(${(L.column-1)*7.8}px + 60px)`},children:[e.jsx("span",{className:"nice-code-editor-ai__ghost-text-content",children:L.text}),e.jsxs("span",{className:"nice-code-editor-ai__ghost-text-hint",children:["Tab ",l("codeEditorAI.toAccept","to accept")]})]})]}),E&&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:["📖 ",l("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>J(!1),children:"✕"})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:B?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:l("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:H}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:g||l("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),v&&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:["🔧 ",l("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{T(!1),c(""),W("")},children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:H}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:l("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:I,onChange:ne=>W(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&I&&O(I)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>O(I),disabled:B||!I,children:B?l("codeEditorAI.refactoring","Refactoring..."):l("codeEditorAI.refactor","Refactor")})]}),x&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:l("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:x}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:ve,children:["✓ ",l("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{c(""),W("")},children:["✕ ",l("codeEditorAI.discard","Discard")]})]})]})]})]})]})});function Wt(n,t){const i=t.getBoundingClientRect();let r,d,h;if("touches"in n){const y=n.touches[0];r=y.clientX-i.left,d=y.clientY-i.top,h=y.force}else"pressure"in n?(r=n.clientX-i.left,d=n.clientY-i.top,h=n.pressure):(r=n.clientX-i.left,d=n.clientY-i.top);return{x:r,y:d,time:Date.now(),pressure:h!==void 0?h:.5}}function Ot(n,t,i,r,d){if(!t)return(i+r)/2;const h=Math.sqrt(Math.pow(n.x-t.x,2)+Math.pow(n.y-t.y,2))/Math.max(1,n.time-t.time),y=Math.min(h/5,1),w=r-y*(r-i),M=n.pressure??.5,S=i+M*(r-i);return w*.7+S*.3}function Bt(n,t,i,r){n.beginPath(),n.moveTo(t.x,t.y),n.lineTo(i.x,i.y),n.lineWidth=r,n.lineCap="round",n.lineJoin="round",n.stroke()}a.forwardRef(function(n,t){const{value:i,onChange:r,width:d="100%",height:h=200,penColor:y="var(--text-primary, #000000)",penWidth:w=2,minWidth:M=.5,maxWidth:S=4,backgroundColor:U="var(--bg-primary, #ffffff)",placeholder:A="Sign here",showClearButton:b=!0,showUndoButton:C=!0,showColorPicker:z=!1,showSizeSlider:K=!1,velocityFilterWeight:X=.7,throttle:G=16,disabled:p=!1,readOnly:L=!1,displayMode:$=!1,onBegin:E,onEnd:J,className:g,"data-testid":k}=n,v=L||$,T=$?!1:b,I=$?!1:C,W=$?!1:z,x=$?!1:K,c=a.useRef(null),[H,_]=a.useState((i==null?void 0:i.strokes)??[]),[j,l]=a.useState([]),[o,m]=a.useState(!1),[s,u]=a.useState(y),[q,B]=a.useState(w),V=a.useRef(null),le=a.useRef(0),R=H.length===0&&j.length===0;a.useEffect(()=>{const se=c.current;if(!se)return;const N=se.getContext("2d");if(!N)return;const D=se.getBoundingClientRect(),Z=window.devicePixelRatio||1;se.width=D.width*Z,se.height=D.height*Z,N.scale(Z,Z),O()},[d,h]);const O=a.useCallback(()=>{const se=c.current;if(!se)return;const N=se.getContext("2d");if(!N)return;const D=se.getBoundingClientRect();N.fillStyle=U,N.fillRect(0,0,D.width,D.height),H.forEach(Z=>{if(N.strokeStyle=Z.color,!(Z.points.length<2))for(let he=1;he<Z.points.length;he++){const me=Z.points[he-1],ae=Z.points[he],ie=Ot(ae,me,M,S);Bt(N,me,ae,ie)}})},[H,U,M,S,X]);a.useEffect(()=>{O()},[O]),a.useEffect(()=>{i!=null&&i.strokes&&_(i.strokes)},[i]),a.useEffect(()=>{const se=c.current;if(se)if(H.length===0)r==null||r(null);else{const N=se.getBoundingClientRect();r==null||r({strokes:H,width:N.width,height:N.height,timestamp:Date.now()})}},[H,r]);const te=a.useCallback(se=>{if(p||v)return;const N=c.current;if(!N)return;N.setPointerCapture(se.pointerId);const D=Wt(se.nativeEvent,N);m(!0),l([D]),V.current=D,le.current=D.time,E==null||E()},[p,v,E]),oe=a.useCallback(se=>{if(!o||p||v)return;const N=c.current;if(!N)return;const D=N.getContext("2d");if(!D)return;const Z=Date.now();if(Z-le.current<G)return;const he=Wt(se.nativeEvent,N),me=V.current;if(me){D.strokeStyle=s;const ae=Ot(he,me,M,S);Bt(D,me,he,ae)}l(ae=>[...ae,he]),V.current=he,le.current=Z},[o,p,v,s,M,S,X,G]),pe=a.useCallback(se=>{if(!o)return;const N=c.current;if(N&&N.releasePointerCapture(se.pointerId),j.length>0){const D={points:j,color:s,width:q};_(Z=>[...Z,D])}m(!1),l([]),V.current=null,J==null||J()},[o,j,s,q,J]),fe=a.useCallback(()=>{_([]),l([]),O()},[O]),ve=a.useCallback(()=>{_(se=>se.slice(0,-1))},[]),ne=a.useCallback((se="png",N=.92)=>{const D=c.current;if(!D)return"";const Z=se==="jpeg"?"image/jpeg":"image/png";return D.toDataURL(Z,N)},[]),re=a.useCallback(async(se="png",N=.92)=>{const D=c.current;return D?new Promise(Z=>{const he=se==="jpeg"?"image/jpeg":"image/png";D.toBlob(me=>Z(me),he,N)}):null},[]),ce=a.useCallback(()=>{const se=c.current;if(!se)return"";const N=se.getBoundingClientRect(),D=H.map(Z=>Z.points.length<2?"":`<path d="${Z.points.reduce((he,me,ae)=>ae===0?`M ${me.x} ${me.y}`:`${he} L ${me.x} ${me.y}`,"")}" stroke="${Z.color}" stroke-width="${Z.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
276
|
+
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${N.width}" height="${N.height}" viewBox="0 0 ${se.width} ${se.height}">
|
|
277
|
+
<rect width="100%" height="100%" fill="${U}"/>
|
|
278
|
+
${D}
|
|
279
|
+
</svg>`},[H,U]);a.useImperativeHandle(t,()=>({clear:fe,undo:ve,isEmpty:()=>H.length===0,getData:()=>{const se=c.current;if(!se||H.length===0)return null;const N=se.getBoundingClientRect();return{strokes:H,width:N.width,height:N.height,timestamp:Date.now()}},setData:se=>{_(se.strokes)},toDataURL:ne,toBlob:re,toSVG:ce,getCanvas:()=>c.current}),[H,fe,ve,ne,re,ce]),a.useEffect(()=>{const se=c.current;if(!se)return;const N=D=>{o&&D.preventDefault()};return se.addEventListener("touchmove",N,{passive:!1}),()=>se.removeEventListener("touchmove",N)},[o]);const ge=T||I||W||x;return e.jsxs("div",{className:`nice-signature ${p?"nice-signature--disabled":""} ${v?"nice-signature--readonly":""} ${g??""}`,style:{width:d},"data-testid":k,children:[ge&&e.jsxs("div",{className:"nice-signature__toolbar",children:[W&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:s,onChange:se=>u(se.target.value),disabled:p||v,title:"Pen color"})}),x&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:M,max:S,step:.5,value:q,onChange:se=>B(parseFloat(se.target.value)),disabled:p||v,title:"Pen size"})}),e.jsxs("div",{className:"nice-signature__actions",children:[I&&e.jsx("button",{type:"button",onClick:ve,disabled:p||v||H.length===0,className:"nice-signature__btn",title:"Undo",children:"↩️"}),T&&e.jsx("button",{type:"button",onClick:fe,disabled:p||v||R,className:"nice-signature__btn",title:"Clear",children:"🗑️"})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:h},children:[e.jsx("canvas",{ref:c,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:p||v?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:te,onPointerMove:oe,onPointerUp:pe,onPointerLeave:pe}),R&&!o&&A&&e.jsx("div",{className:"nice-signature__placeholder",children:A}),e.jsx("div",{className:"nice-signature__line"})]})]})});const Ft="nice-signature-styles";if(typeof document<"u"&&!document.getElementById(Ft)){const n=document.createElement("style");n.id=Ft,n.textContent=`
|
|
280
|
+
.nice-signature {
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-direction: column;
|
|
283
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
284
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
background: var(--nice-bg-surface, #fff);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.nice-signature--disabled {
|
|
290
|
+
opacity: 0.6;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.nice-signature__toolbar {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: var(--nice-space-2, 8px);
|
|
297
|
+
padding: var(--nice-space-2, 8px);
|
|
298
|
+
background: var(--nice-bg-muted, #f5f5f5);
|
|
299
|
+
border-bottom: 1px solid var(--nice-border, #e0e0e0);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.nice-signature__color-picker input {
|
|
303
|
+
width: 32px;
|
|
304
|
+
height: 32px;
|
|
305
|
+
padding: var(--nice-space-0-5, 2px);
|
|
306
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
307
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
308
|
+
cursor: pointer;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.nice-signature__size-slider {
|
|
312
|
+
flex: 1;
|
|
313
|
+
max-width: 120px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.nice-signature__size-slider input {
|
|
317
|
+
width: 100%;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.nice-signature__actions {
|
|
321
|
+
display: flex;
|
|
322
|
+
gap: var(--nice-space-1, 4px);
|
|
323
|
+
margin-left: auto;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-signature__btn {
|
|
327
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
|
|
328
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
329
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
330
|
+
background: var(--nice-bg-surface, #fff);
|
|
331
|
+
cursor: pointer;
|
|
332
|
+
font-size: 14px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.nice-signature__btn:hover:not(:disabled) {
|
|
336
|
+
background: var(--nice-bg-hover, #f0f0f0);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.nice-signature__btn:disabled {
|
|
340
|
+
opacity: 0.4;
|
|
341
|
+
cursor: not-allowed;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.nice-signature__canvas-wrapper {
|
|
345
|
+
position: relative;
|
|
346
|
+
background: var(--nice-bg, #FFF);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.nice-signature__canvas {
|
|
350
|
+
display: block;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-signature__placeholder {
|
|
354
|
+
position: absolute;
|
|
355
|
+
top: 50%;
|
|
356
|
+
left: 50%;
|
|
357
|
+
transform: translate(-50%, -50%);
|
|
358
|
+
color: var(--nice-text-secondary, #999);
|
|
359
|
+
font-size: 14px;
|
|
360
|
+
pointer-events: none;
|
|
361
|
+
user-select: none;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.nice-signature__line {
|
|
365
|
+
position: absolute;
|
|
366
|
+
bottom: 30px;
|
|
367
|
+
left: 20px;
|
|
368
|
+
right: 20px;
|
|
369
|
+
height: 1px;
|
|
370
|
+
background: var(--nice-border, #ccc);
|
|
371
|
+
pointer-events: none;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Display component */
|
|
375
|
+
.nice-signature-display {
|
|
376
|
+
border: 1px solid var(--nice-border, #e0e0e0);
|
|
377
|
+
border-radius: var(--nice-radius-sm, 4px);
|
|
378
|
+
overflow: hidden;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.nice-signature-display__canvas-wrapper {
|
|
382
|
+
position: relative;
|
|
383
|
+
background: var(--nice-bg, #FFF);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.nice-signature-display__canvas {
|
|
387
|
+
display: block;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.nice-signature-display__placeholder {
|
|
391
|
+
position: absolute;
|
|
392
|
+
top: 50%;
|
|
393
|
+
left: 50%;
|
|
394
|
+
transform: translate(-50%, -50%);
|
|
395
|
+
color: var(--nice-text-secondary, #999);
|
|
396
|
+
font-size: 14px;
|
|
397
|
+
}
|
|
398
|
+
`,document.head.appendChild(n)}const ma={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function ga(n,t){switch(t.type){case"SET_TOOL":return{...n,activeTool:t.tool,selectedId:null};case"SET_STYLE":return{...n,style:{...n.style,...t.style}};case"ADD_ANNOTATION":return{...n,annotations:[...n.annotations,t.annotation],past:[...n.past,n.annotations],future:[]};case"UPDATE_ANNOTATION":return{...n,annotations:n.annotations.map(i=>i.id===t.id?{...i,...t.updates}:i),past:[...n.past,n.annotations],future:[]};case"DELETE_ANNOTATION":return{...n,annotations:n.annotations.filter(i=>i.id!==t.id),selectedId:n.selectedId===t.id?null:n.selectedId,past:[...n.past,n.annotations],future:[]};case"SELECT":return{...n,selectedId:t.id};case"SET_ANNOTATIONS":return{...n,annotations:t.annotations,past:[],future:[]};case"SET_ZOOM":return{...n,zoom:t.zoom};case"SET_PAN":return{...n,panX:t.panX,panY:t.panY};case"UNDO":{if(n.past.length===0)return n;const i=n.past[n.past.length-1];return{...n,annotations:i,past:n.past.slice(0,-1),future:[n.annotations,...n.future]}}case"REDO":{if(n.future.length===0)return n;const i=n.future[0];return{...n,annotations:i,past:[...n.past,n.annotations],future:n.future.slice(1)}}case"CLEAR":return{...n,annotations:[],selectedId:null,past:[...n.past,n.annotations],future:[]};default:return n}}let fa=0;function ba(){return`ann-${Date.now()}-${fa++}`}function xa(n){const{style:t}=n,i=`stroke="${t.strokeColor}" stroke-width="${t.strokeWidth}" fill="${t.fillColor}" opacity="${t.opacity}"`;switch(n.tool){case"rectangle":return`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" ${i} />`;case"ellipse":{const r=n.x+n.width/2,d=n.y+n.height/2;return`<ellipse cx="${r}" cy="${d}" rx="${n.width/2}" ry="${n.height/2}" ${i} />`}case"arrow":{const r=n,d=Math.atan2(r.endY-r.y,r.endX-r.x),h=12,y=r.endX-h*Math.cos(d-Math.PI/6),w=r.endY-h*Math.sin(d-Math.PI/6),M=r.endX-h*Math.cos(d+Math.PI/6),S=r.endY-h*Math.sin(d+Math.PI/6);return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${i} />
|
|
399
|
+
<polygon points="${r.endX},${r.endY} ${y},${w} ${M},${S}" fill="${t.strokeColor}" opacity="${t.opacity}" />`}case"line":{const r=n;return`<line x1="${r.x}" y1="${r.y}" x2="${r.endX}" y2="${r.endY}" ${i} />`}case"text":{const r=n;return`<text x="${r.x}" y="${r.y+(r.style.fontSize??16)}" fill="${t.strokeColor}" font-size="${t.fontSize}" font-family="${t.fontFamily}" opacity="${t.opacity}">${va(r.text)}</text>`}case"freehand":{const r=n;return r.points.length<2?"":`<path d="${r.points.map((d,h)=>`${h===0?"M":"L"}${d.x},${d.y}`).join(" ")}" ${i} fill="none" />`}case"blur":{const r=n,d=`blur-${r.id}`;return`<defs><filter id="${d}"><feGaussianBlur stdDeviation="${r.intensity??5}" /></filter></defs>
|
|
400
|
+
<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="transparent" stroke="none" filter="url(#${d})" />`}default:return""}}function va(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const fn=a.forwardRef(({src:n,alt:t="Annotatable image",annotations:i,activeTool:r,defaultStyle:d,onAnnotationsChange:h,className:y,readOnly:w=!1,minZoom:M=.1,maxZoom:S=5},U)=>{const A=a.useRef(null),b=a.useRef(null),C=a.useRef(null),[z,K]=a.useState(!1),[X,G]=a.useState({width:0,height:0}),[p,L]=a.useReducer(ga,{annotations:i??[],selectedId:null,activeTool:r??"select",style:{...ma,...d},zoom:1,panX:0,panY:0,past:[],future:[]});a.useEffect(()=>{r&&L({type:"SET_TOOL",tool:r})},[r]),a.useEffect(()=>{h==null||h(p.annotations)},[p.annotations,h]),a.useEffect(()=>{const x=new Image;x.crossOrigin="anonymous",x.onload=()=>{C.current=x,G({width:x.naturalWidth,height:x.naturalHeight}),K(!0)},x.src=n},[n]);const $=a.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),E=a.useCallback((x,c)=>{const H=A.current;if(!H)return{x:0,y:0};const _=H.getBoundingClientRect();return{x:(x-_.left-p.panX)/p.zoom,y:(c-_.top-p.panY)/p.zoom}},[p.zoom,p.panX,p.panY]),J=a.useCallback(()=>{var j,l;const x=A.current,c=x==null?void 0:x.getContext("2d"),H=C.current;if(!x||!c||!H||!z)return;x.width=((j=b.current)==null?void 0:j.clientWidth)??H.naturalWidth,x.height=((l=b.current)==null?void 0:l.clientHeight)??H.naturalHeight,c.clearRect(0,0,x.width,x.height),c.save(),c.translate(p.panX,p.panY),c.scale(p.zoom,p.zoom),c.drawImage(H,0,0);for(const o of p.annotations){switch(c.save(),c.globalAlpha=o.style.opacity,c.strokeStyle=o.style.strokeColor,c.fillStyle=o.style.fillColor,c.lineWidth=o.style.strokeWidth,o.tool){case"rectangle":c.strokeRect(o.x,o.y,o.width,o.height),o.style.fillColor!=="transparent"&&c.fillRect(o.x,o.y,o.width,o.height);break;case"ellipse":{c.beginPath(),c.ellipse(o.x+o.width/2,o.y+o.height/2,Math.abs(o.width/2),Math.abs(o.height/2),0,0,Math.PI*2),c.stroke(),o.style.fillColor!=="transparent"&&c.fill();break}case"arrow":{const m=o;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke();const s=Math.atan2(m.endY-m.y,m.endX-m.x),u=12;c.beginPath(),c.moveTo(m.endX,m.endY),c.lineTo(m.endX-u*Math.cos(s-Math.PI/6),m.endY-u*Math.sin(s-Math.PI/6)),c.lineTo(m.endX-u*Math.cos(s+Math.PI/6),m.endY-u*Math.sin(s+Math.PI/6)),c.closePath(),c.fillStyle=o.style.strokeColor,c.fill();break}case"line":{const m=o;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke();break}case"text":{const m=o;c.font=`${m.style.fontSize??16}px ${m.style.fontFamily??"sans-serif"}`,c.fillStyle=m.style.strokeColor,c.fillText(m.text,m.x,m.y+(m.style.fontSize??16));break}case"freehand":{const m=o;if(m.points.length<2)break;c.beginPath(),c.moveTo(m.points[0].x,m.points[0].y);for(let s=1;s<m.points.length;s++)c.lineTo(m.points[s].x,m.points[s].y);c.stroke();break}case"blur":{const m=o;c.filter=`blur(${m.intensity??5}px)`,c.drawImage(H,m.x,m.y,m.width,m.height,m.x,m.y,m.width,m.height),c.filter="none";break}}o.id===p.selectedId&&(c.strokeStyle="#4488ff",c.lineWidth=1,c.setLineDash([4,4]),c.strokeRect(o.x-2,o.y-2,o.width+4,o.height+4),c.setLineDash([])),c.restore()}const _=$.current;if(_.isDrawing&&_.currentAnnotation){c.save();const o=_.currentAnnotation;if(c.globalAlpha=o.style.opacity,c.strokeStyle=o.style.strokeColor,c.lineWidth=o.style.strokeWidth,c.setLineDash([6,3]),o.tool==="freehand"){const m=o;if(m.points.length>=2){c.beginPath(),c.moveTo(m.points[0].x,m.points[0].y);for(let s=1;s<m.points.length;s++)c.lineTo(m.points[s].x,m.points[s].y);c.stroke()}}else if(o.tool==="rectangle")c.strokeRect(o.x,o.y,o.width,o.height);else if(o.tool==="ellipse")c.beginPath(),c.ellipse(o.x+o.width/2,o.y+o.height/2,Math.abs(o.width/2),Math.abs(o.height/2),0,0,Math.PI*2),c.stroke();else if(o.tool==="arrow"||o.tool==="line"){const m=o;c.beginPath(),c.moveTo(m.x,m.y),c.lineTo(m.endX,m.endY),c.stroke()}c.restore()}c.restore()},[p,z]);a.useEffect(()=>{J()},[J]);const g=a.useCallback(x=>{if(w)return;const c=E(x.clientX,x.clientY),H=p.activeTool;if(H==="select"){const l=[...p.annotations].reverse().find(o=>o.tool==="freehand"?!1:c.x>=o.x&&c.x<=o.x+o.width&&c.y>=o.y&&c.y<=o.y+o.height);L({type:"SELECT",id:(l==null?void 0:l.id)??null});return}const _=$.current;_.isDrawing=!0,_.startX=c.x,_.startY=c.y;const j={id:ba(),style:{...p.style},x:c.x,y:c.y,width:0,height:0};switch(H){case"rectangle":_.currentAnnotation={...j,tool:"rectangle"};break;case"ellipse":_.currentAnnotation={...j,tool:"ellipse"};break;case"arrow":_.currentAnnotation={...j,tool:"arrow",endX:c.x,endY:c.y};break;case"line":_.currentAnnotation={...j,tool:"line",endX:c.x,endY:c.y};break;case"text":_.currentAnnotation={...j,tool:"text",text:"Text",width:100,height:p.style.fontSize??16};break;case"freehand":_.freehandPoints=[c],_.currentAnnotation={...j,tool:"freehand",points:[c]};break;case"blur":_.currentAnnotation={...j,tool:"blur",intensity:5};break}},[w,E,p.activeTool,p.style,p.annotations]),k=a.useCallback(x=>{const c=$.current;if(!c.isDrawing||!c.currentAnnotation)return;const H=E(x.clientX,x.clientY),_=c.currentAnnotation;if(_.tool==="freehand"){c.freehandPoints.push(H),_.points=[...c.freehandPoints];const j=c.freehandPoints.map(o=>o.x),l=c.freehandPoints.map(o=>o.y);_.x=Math.min(...j),_.y=Math.min(...l),_.width=Math.max(...j)-_.x,_.height=Math.max(...l)-_.y}else if(_.tool==="arrow"||_.tool==="line")_.endX=H.x,_.endY=H.y,_.width=Math.abs(H.x-c.startX),_.height=Math.abs(H.y-c.startY);else{const j=Math.min(c.startX,H.x),l=Math.min(c.startY,H.y);_.x=j,_.y=l,_.width=Math.abs(H.x-c.startX),_.height=Math.abs(H.y-c.startY)}J()},[E,J]),v=a.useCallback(()=>{const x=$.current;if(!x.isDrawing||!x.currentAnnotation)return;const c=x.currentAnnotation;(c.tool==="text"||c.tool==="freehand"||Math.abs(c.width)>2||Math.abs(c.height)>2)&&L({type:"ADD_ANNOTATION",annotation:c}),x.isDrawing=!1,x.currentAnnotation=null,x.freehandPoints=[]},[]),T=a.useCallback(x=>{x.preventDefault();const c=x.deltaY>0?.9:1.1,H=Math.max(M,Math.min(S,p.zoom*c));L({type:"SET_ZOOM",zoom:H})},[p.zoom,M,S]);a.useEffect(()=>{if(w)return;const x=c=>{(c.metaKey||c.ctrlKey)&&c.key==="z"&&!c.shiftKey?(c.preventDefault(),L({type:"UNDO"})):(c.metaKey||c.ctrlKey)&&(c.key==="y"||c.key==="z"&&c.shiftKey)?(c.preventDefault(),L({type:"REDO"})):(c.key==="Delete"||c.key==="Backspace")&&p.selectedId&&L({type:"DELETE_ANNOTATION",id:p.selectedId})};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[w,p.selectedId]),a.useImperativeHandle(U,()=>({exportAsDataURL:async(x="png",c=.92)=>{const H=document.createElement("canvas"),_=C.current;if(!_)return"";H.width=_.naturalWidth,H.height=_.naturalHeight;const j=H.getContext("2d");j.drawImage(_,0,0);for(const l of p.annotations){if(j.save(),j.globalAlpha=l.style.opacity,j.strokeStyle=l.style.strokeColor,j.fillStyle=l.style.fillColor,j.lineWidth=l.style.strokeWidth,l.tool==="rectangle")j.strokeRect(l.x,l.y,l.width,l.height);else if(l.tool==="ellipse")j.beginPath(),j.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),j.stroke();else if(l.tool==="freehand"){const o=l;if(o.points.length>=2){j.beginPath(),j.moveTo(o.points[0].x,o.points[0].y);for(let m=1;m<o.points.length;m++)j.lineTo(o.points[m].x,o.points[m].y);j.stroke()}}else if(l.tool==="text"){const o=l;j.font=`${o.style.fontSize??16}px ${o.style.fontFamily??"sans-serif"}`,j.fillStyle=o.style.strokeColor,j.fillText(o.text,o.x,o.y+(o.style.fontSize??16))}j.restore()}return H.toDataURL(`image/${x}`,c)},exportAnnotations:()=>[...p.annotations],importAnnotations:x=>{L({type:"SET_ANNOTATIONS",annotations:x})},exportAsSVG:()=>{const{width:x,height:c}=X,H=p.annotations.map(xa);return`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${c}" viewBox="0 0 ${x} ${c}">
|
|
401
|
+
${H.join(`
|
|
402
|
+
`)}
|
|
403
|
+
</svg>`},undo:()=>L({type:"UNDO"}),redo:()=>L({type:"REDO"}),setZoom:x=>{L({type:"SET_ZOOM",zoom:Math.max(M,Math.min(S,x))})},fitToScreen:()=>{const x=b.current,c=C.current;if(!x||!c)return;const H=x.clientWidth/c.naturalWidth,_=x.clientHeight/c.naturalHeight,j=Math.min(H,_,1);L({type:"SET_ZOOM",zoom:j}),L({type:"SET_PAN",panX:0,panY:0})},clear:()=>L({type:"CLEAR"})}),[p.annotations,X,M,S]);const I=a.useCallback(x=>{if(x.touches.length!==1)return;const c=x.touches[0];g({clientX:c.clientX,clientY:c.clientY,preventDefault:()=>{}})},[g]),W=a.useCallback(x=>{if(x.touches.length!==1)return;const c=x.touches[0];k({clientX:c.clientX,clientY:c.clientY})},[k]);return e.jsx("div",{ref:b,className:`nice-image-annotator ${y??""}`,style:{position:"relative",overflow:"hidden",width:"100%",height:"100%"},children:e.jsx("canvas",{ref:A,className:"nice-image-annotator__canvas",style:{cursor:p.activeTool==="select"?"default":"crosshair"},onMouseDown:g,onMouseMove:k,onMouseUp:v,onMouseLeave:v,onWheel:T,onTouchStart:I,onTouchMove:W,onTouchEnd:v,role:"img","aria-label":t})})});fn.displayName="NiceImageAnnotator";function ya(n){let t=n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(i,r,d)=>`<pre><code class="language-${r}">${d.trim()}</code></pre>`),t=t.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(i,r,d,h)=>{const y=r.split("|").filter(M=>M.trim()).map(M=>`<th>${M.trim()}</th>`).join(""),w=h.trim().split(`
|
|
404
|
+
`).map(M=>`<tr>${M.split("|").filter(S=>S.trim()).map(S=>`<td>${S.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${y}</tr></thead><tbody>${w}</tbody></table>`}),t=t.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^# (.+)$/gm,"<h1>$1</h1>"),t=t.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),t=t.replace(/^---$/gm,"<hr/>"),t=t.replace(/^- \[x\] (.+)$/gm,'<li class="task done">☑ $1</li>'),t=t.replace(/^- \[ \] (.+)$/gm,'<li class="task">☐ $1</li>'),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*(.+?)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/`(.+?)`/g,"<code>$1</code>"),t=t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),t=t.replace(/^\- (.+)$/gm,"<li>$1</li>"),t=t.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),t=t.replace(/\n/g,"<br/>"),t}const _a=[{key:"bold",label:"B",md:"**",tip:"Bold",shortcut:"Ctrl+B",group:"format"},{key:"italic",label:"I",md:"*",tip:"Italic",shortcut:"Ctrl+I",group:"format"},{key:"strike",label:"S̶",md:"~~",tip:"Strikethrough",group:"format"},{key:"code",label:"< >",md:"`",tip:"Inline code",group:"format"},{key:"h1",label:"H1",md:"# ",tip:"Heading 1",group:"heading"},{key:"h2",label:"H2",md:"## ",tip:"Heading 2",group:"heading"},{key:"h3",label:"H3",md:"### ",tip:"Heading 3",group:"heading"},{key:"ul",label:"•",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",label:"☑",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",label:"❝",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",label:"—",md:`---
|
|
405
|
+
`,tip:"Horizontal rule",group:"block"},{key:"link",label:"🔗",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",label:"🖼",md:"",tip:"Image",group:"insert"},{key:"table",label:"⊞",md:`| H1 | H2 | H3 |
|
|
406
|
+
| --- | --- | --- |
|
|
407
|
+
| c1 | c2 | c3 |
|
|
408
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],ka=["format","heading","list","block","insert"],bn=a.forwardRef(({value:n="",onChange:t,preview:i="side",placeholder:r,disabled:d,readOnly:h,size:y="md",editorSize:w="standard",toolbar:M=!0,minHeight:S=200,showWordCount:U=!1,showLineNumbers:A=!1,onExportHtml:b,onImageUpload:C,className:z,style:K,id:X},G)=>{const p=P.nl(X),[L,$]=a.useState("edit"),[E,J]=a.useState(!1),g=a.useRef(null),k=a.useMemo(()=>ya(n),[n]),v=a.useMemo(()=>{const _=n.trim()?n.trim().split(/\s+/).length:0,j=n.length,l=n.split(`
|
|
409
|
+
`).length;return{words:_,chars:j,lines:l}},[n]),T=a.useCallback(_=>{const j=g.current;if(!j)return;const l=j.selectionStart,o=j.selectionEnd,m=n.slice(l,o);let s,u;_==="[](url)"?(s=n.slice(0,l)+`[${m||"text"}](url)`+n.slice(o),u=l+1+(m||"text").length+2):_===""?(s=n.slice(0,l)+``+n.slice(o),u=l+2+(m||"alt").length+2):_.endsWith(`
|
|
410
|
+
`)||_.endsWith(" ")?(s=n.slice(0,l)+_+m+n.slice(o),u=l+_.length+m.length):(s=n.slice(0,l)+_+m+_+n.slice(o),u=l+_.length+m.length+_.length),t==null||t(s),requestAnimationFrame(()=>{j.focus(),j.setSelectionRange(u,u)})},[n,t]),I=a.useCallback(_=>{if((_.ctrlKey||_.metaKey)&&(_.key==="b"?(_.preventDefault(),T("**")):_.key==="i"?(_.preventDefault(),T("*")):_.key==="k"&&(_.preventDefault(),T("[](url)"))),_.key==="Tab"){_.preventDefault();const j=_.currentTarget,l=j.selectionStart,o=j.selectionEnd,m=" ";if(_.shiftKey){const s=n.slice(0,l).lastIndexOf(`
|
|
411
|
+
`)+1;if(n.slice(s,s+m.length)===m){const u=n.slice(0,s)+n.slice(s+m.length);t==null||t(u),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=l-m.length})}}else{const s=n.slice(0,l)+m+n.slice(o);t==null||t(s),requestAnimationFrame(()=>{j.selectionStart=j.selectionEnd=l+m.length})}}},[n,t,T]),W=a.useCallback(async _=>{if(!C)return;const j=Array.from(_.dataTransfer.files).filter(l=>l.type.startsWith("image/"));if(j.length!==0){_.preventDefault();for(const l of j){const o=await C(l),m=g.current;if(!m)continue;const s=m.selectionStart,u=`
|
|
412
|
+
`,q=n.slice(0,s)+u+n.slice(s);t==null||t(q)}}},[n,t,C]),x=i!=="tab"||L==="edit",c=i==="side"||i==="tab"&&L==="preview"||i===!0,H=`nice-md-editor nice-md-editor--${y} nice-editor--${w} nice-md-editor--preview-${i}${E?" nice-md-editor--fullscreen":""} ${z||""}`;return e.jsxs("div",{ref:G,id:p,className:H,style:K,children:[M&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[ka.map((_,j)=>e.jsxs(a.Fragment,{children:[j>0&&e.jsx("span",{className:"nice-md-editor__sep"}),_a.filter(l=>l.group===_).map(l=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:l.shortcut?`${l.tip} (${l.shortcut})`:l.tip,disabled:d||h,onClick:()=>T(l.md),children:l.label},l.key))]},_)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Fullscreen",onClick:()=>J(!E),children:E?"⊙":"⛶"}),b&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:"Export HTML",onClick:()=>b(k),children:"↗"}),i==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${L==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>$("edit"),children:"Edit"}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${L==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>$("preview"),children:"Preview"})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:S},children:[x&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[A&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:v.lines},(_,j)=>e.jsx("div",{className:"nice-md-editor__line-no",children:j+1},j))}),e.jsx("textarea",{ref:g,className:"nice-md-editor__textarea",value:n,onChange:_=>t==null?void 0:t(_.target.value),onKeyDown:I,onDrop:W,placeholder:r,disabled:d,readOnly:h,style:{minHeight:S}})]}),c&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:P.Ys(k)},style:{minHeight:S}})]}),U&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsxs("span",{children:[v.words," words"]}),e.jsxs("span",{children:[v.chars," chars"]}),e.jsxs("span",{children:[v.lines," lines"]})]})]})});bn.displayName="NiceMarkdownEditor";const Ut={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},ja=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],xn=a.forwardRef(({src:n,size:t="md",editorSize:i="standard",tools:r=ja,showToolbar:d=!0,showZoom:h=!0,maxUndo:y=30,onSave:w,onCancel:M,onChange:S,width:U="100%",height:A=500,className:b,style:C,id:z,...K},X)=>{const G=P.nl(z),{t:p}=P.ue(),L=a.useRef(null),$=a.useRef(null),[E,J]=a.useState({...Ut}),[g,k]=a.useState(null),[v,T]=a.useState(!1),[I,W]=a.useState(1),[x,c]=a.useState("rect"),[H,_]=a.useState("var(--nice-danger, #ff0000)"),[j,l]=a.useState({w:0,h:0}),[o,m]=a.useState([]),[s,u]=a.useState([]),[q,B]=a.useState(null),[V,le]=a.useState(null),[R,O]=a.useState(null),te=a.useCallback(N=>{m(D=>[...D.slice(-(y-1)),N]),u([])},[y]),oe=a.useCallback(N=>{J(D=>{te(D);const Z={...D,...N};return S==null||S(Z),Z})},[S,te]),pe=a.useCallback(()=>{if(o.length===0)return;const N=o[o.length-1];m(D=>D.slice(0,-1)),u(D=>[...D,E]),J(N),S==null||S(N)},[o,E,S]),fe=a.useCallback(()=>{if(s.length===0)return;const N=s[s.length-1];u(D=>D.slice(0,-1)),m(D=>[...D,E]),J(N),S==null||S(N)},[s,E,S]);a.useEffect(()=>{const N=new Image;N.crossOrigin="anonymous",N.onload=()=>{$.current=N,l({w:N.width,h:N.height}),T(!0)},N.src=n},[n]),a.useEffect(()=>{if(!v||!L.current||!$.current)return;const N=L.current,D=N.getContext("2d");if(!D)return;const Z=$.current,he=E.rotation%180!==0,me=he?Z.height:Z.width,ae=he?Z.width:Z.height;N.width=me,N.height=ae,D.clearRect(0,0,me,ae),D.save(),D.filter=`brightness(${E.brightness}%) contrast(${E.contrast}%) saturate(${E.saturate}%) blur(${E.blur}px)`,D.translate(me/2,ae/2),D.rotate(E.rotation*Math.PI/180),D.scale(E.flipH?-1:1,E.flipV?-1:1),D.drawImage(Z,-Z.width/2,-Z.height/2),D.restore(),E.annotations.forEach(ie=>{switch(D.save(),D.strokeStyle=ie.color??"red",D.fillStyle=ie.color??"red",D.lineWidth=ie.strokeWidth??2,D.font=`${ie.fontSize??16}px sans-serif`,ie.type){case"text":D.fillText(ie.text??"",ie.x,ie.y);break;case"rect":D.strokeRect(ie.x,ie.y,ie.width??100,ie.height??50);break;case"circle":{const ke=(ie.width??50)/2,be=(ie.height??50)/2;D.beginPath(),D.ellipse(ie.x+ke,ie.y+be,ke,be,0,0,Math.PI*2),D.stroke();break}case"line":D.beginPath(),D.moveTo(ie.x,ie.y),D.lineTo(ie.x+(ie.width??100),ie.y+(ie.height??0)),D.stroke();break;case"arrow":{const ke=ie.x+(ie.width??100),be=ie.y+(ie.height??0);D.beginPath(),D.moveTo(ie.x,ie.y),D.lineTo(ke,be),D.stroke();const Ee=Math.atan2(be-ie.y,ke-ie.x),je=10;D.beginPath(),D.moveTo(ke,be),D.lineTo(ke-je*Math.cos(Ee-.4),be-je*Math.sin(Ee-.4)),D.lineTo(ke-je*Math.cos(Ee+.4),be-je*Math.sin(Ee+.4)),D.closePath(),D.fill();break}}D.restore()}),V&&(D.save(),D.fillStyle="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",D.fillRect(0,0,me,ae),D.clearRect(V.x,V.y,V.w,V.h),D.strokeStyle="var(--bg-primary, #fff)",D.lineWidth=2,D.setLineDash([5,5]),D.strokeRect(V.x,V.y,V.w,V.h),D.restore())},[v,E,V]);const ve=a.useCallback(N=>{if(!L.current)return;const D=L.current.getBoundingClientRect(),Z=L.current.width/D.width,he=L.current.height/D.height,me=(N.clientX-D.left)*Z,ae=(N.clientY-D.top)*he;g==="crop"?B({startX:me,startY:ae}):g==="annotate"&&O({startX:me,startY:ae})},[g]),ne=a.useCallback(N=>{if(!L.current)return;const D=L.current.getBoundingClientRect(),Z=L.current.width/D.width,he=L.current.height/D.height,me=(N.clientX-D.left)*Z,ae=(N.clientY-D.top)*he;q&&le({x:Math.min(q.startX,me),y:Math.min(q.startY,ae),w:Math.abs(me-q.startX),h:Math.abs(ae-q.startY)})},[q]),re=a.useCallback(N=>{if(q&&V&&V.w>5&&V.h>5&&oe({crop:{x:V.x,y:V.y,width:V.w,height:V.h}}),B(null),R&&L.current){const D=L.current.getBoundingClientRect(),Z=L.current.width/D.width,he=L.current.height/D.height,me=(N.clientX-D.left)*Z,ae=(N.clientY-D.top)*he,ie=me-R.startX,ke=ae-R.startY;if(Math.abs(ie)>3||Math.abs(ke)>3||x==="text"){const be={type:x,x:R.startX,y:R.startY,width:Math.abs(ie)||100,height:Math.abs(ke)||50,color:H,strokeWidth:2,text:x==="text"?prompt(p("imageEditor.annotationText","Text:"))??"":void 0};oe({annotations:[...E.annotations,be]})}O(null)}},[q,V,R,x,H,E.annotations,oe,p]),ce=a.useCallback(()=>{if(!E.crop||!L.current)return;const N=L.current,D=N.getContext("2d");if(!D)return;const{x:Z,y:he,width:me,height:ae}=E.crop,ie=D.getImageData(Z,he,me,ae);N.width=me,N.height=ae,D.putImageData(ie,0,0),le(null),k(null)},[E.crop]),ge=a.useCallback(()=>{if(!L.current)return;const N=L.current.toDataURL("image/png");w==null||w(N,E)},[w,E]),se=a.useCallback(()=>{J({...Ut}),le(null),k(null)},[]);return a.useMemo(()=>`brightness(${E.brightness}%) contrast(${E.contrast}%) saturate(${E.saturate}%) blur(${E.blur}px)`,[E.brightness,E.contrast,E.saturate,E.blur]),e.jsxs("div",{ref:X,id:G,className:`nice-image-editor nice-image-editor--${t} nice-editor--${i} ${b??""}`,style:{...C,width:U,height:A},role:"application","aria-label":p("imageEditor.label","Image Editor"),...K,children:[d&&e.jsxs("div",{className:"nice-image-editor__toolbar",role:"toolbar",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:pe,disabled:o.length===0,title:p("imageEditor.undo","Undo"),children:"↶"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:fe,disabled:s.length===0,title:p("imageEditor.redo","Redo"),children:"↷"}),e.jsx("span",{className:"nice-image-editor__sep"}),r.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({rotation:(E.rotation-90+360)%360}),title:p("imageEditor.rotateLeft","Rotate left"),children:"↺"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({rotation:(E.rotation+90)%360}),title:p("imageEditor.rotateRight","Rotate right"),children:"↻"})]}),r.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({flipH:!E.flipH}),title:p("imageEditor.flipH","Flip horizontal"),children:"⇔"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({flipV:!E.flipV}),title:p("imageEditor.flipV","Flip vertical"),children:"⇕"})]}),r.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${g==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>k(g==="crop"?null:"crop"),title:p("imageEditor.crop","Crop"),children:"⊡"}),g==="crop"&&E.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:ce,title:p("imageEditor.applyCrop","Apply crop"),children:"✓"})]}),r.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.brightness","☀"),e.jsx("input",{type:"range",min:0,max:200,value:E.brightness,onChange:N=>oe({brightness:Number(N.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.brightness","Brightness")})]}),r.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.contrast","◑"),e.jsx("input",{type:"range",min:0,max:200,value:E.contrast,onChange:N=>oe({contrast:Number(N.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.contrast","Contrast")})]}),r.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.saturate","🎨"),e.jsx("input",{type:"range",min:0,max:200,value:E.saturate,onChange:N=>oe({saturate:Number(N.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.saturate","Saturation")})]}),r.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",children:[p("imageEditor.blur","⊘"),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:E.blur,onChange:N=>oe({blur:Number(N.target.value)}),className:"nice-image-editor__slider",title:p("imageEditor.blur","Blur")})]}),r.includes("annotate")&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:`nice-image-editor__btn ${g==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>k(g==="annotate"?null:"annotate"),title:p("imageEditor.annotate","Annotate"),children:"✎"}),g==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:x,onChange:N=>c(N.target.value),children:[e.jsx("option",{value:"rect",children:"□ Rect"}),e.jsx("option",{value:"circle",children:"○ Circle"}),e.jsx("option",{value:"line",children:"╱ Line"}),e.jsx("option",{value:"arrow",children:"→ Arrow"}),e.jsx("option",{value:"text",children:"T Text"})]}),e.jsx("input",{type:"color",value:H,onChange:N=>_(N.target.value),className:"nice-image-editor__color",title:p("imageEditor.color","Color")}),E.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>oe({annotations:E.annotations.slice(0,-1)}),title:p("imageEditor.removeLastAnnotation","Remove last"),children:"⌫"})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:se,title:p("imageEditor.reset","Reset"),children:"⟲"}),w&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:ge,children:p("imageEditor.save","Save")}),M&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:M,children:p("imageEditor.cancel","Cancel")})]}),e.jsx("div",{className:"nice-image-editor__canvas-wrap",children:e.jsx("canvas",{ref:L,className:"nice-image-editor__canvas",onMouseDown:ve,onMouseMove:ne,onMouseUp:re,style:{cursor:g==="crop"||g==="annotate"?"crosshair":"default",transform:`scale(${I})`,transformOrigin:"center center"}})}),h&&e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(N=>Math.max(.1,N-.1)),title:"Zoom out",children:"−"}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(I*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(N=>Math.min(5,N+.1)),title:"Zoom in",children:"+"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>W(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:[j.w,"×",j.h,"px · ",E.rotation,"°"]})]})]})});xn.displayName="NiceImageEditor";const vn=a.forwardRef(({value:n,onChange:t,penColor:i="var(--text-primary, #000)",penWidth:r=2,backgroundColor:d="var(--bg-primary, #fff)",width:h=400,height:y=200,size:w="md",disabled:M=!1,readOnly:S=!1,showClear:U=!0,showUndo:A=!0,label:b,exportFormat:C="image/png",className:z,style:K,id:X,...G},p)=>{const L=P.nl(X),{t:$}=P.ue(),E=a.useRef(null),[J,g]=a.useState(!1),k=a.useRef([]),v=a.useRef([]),[T,I]=a.useState(!0),W=a.useCallback(()=>{const o=E.current;if(!o)return;const m=o.getContext("2d");if(m){m.fillStyle=d,m.fillRect(0,0,o.width,o.height),m.strokeStyle=i,m.lineWidth=r,m.lineCap="round",m.lineJoin="round";for(const s of k.current)if(!(s.length<2)){m.beginPath(),m.moveTo(s[0].x,s[0].y);for(let u=1;u<s.length;u++)m.lineTo(s[u].x,s[u].y);m.stroke()}}},[d,i,r]);a.useEffect(()=>{if(n&&E.current){const o=new Image;o.onload=()=>{var s;const m=(s=E.current)==null?void 0:s.getContext("2d");!m||!E.current||(m.fillStyle=d,m.fillRect(0,0,E.current.width,E.current.height),m.drawImage(o,0,0),I(!1))},o.src=n}else n||(k.current=[],I(!0),W())},[n,d,W]),a.useEffect(()=>{const o=E.current;o&&(o.width=h,o.height=y,W())},[h,y,W]);const x=a.useCallback(o=>{const m=E.current,s=m.getBoundingClientRect(),u=m.width/s.width,q=m.height/s.height;if("touches"in o){const B=o.touches[0];return{x:(B.clientX-s.left)*u,y:(B.clientY-s.top)*q}}return{x:(o.clientX-s.left)*u,y:(o.clientY-s.top)*q}},[]),c=a.useCallback(o=>{if(M||S)return;o.preventDefault();const m=x(o);v.current=[m],g(!0)},[M,S,x]),H=a.useCallback(o=>{if(!J)return;o.preventDefault();const m=x(o);v.current.push(m);const s=E.current,u=s==null?void 0:s.getContext("2d");if(!u||!s)return;const q=v.current;q.length>=2&&(u.strokeStyle=i,u.lineWidth=r,u.lineCap="round",u.beginPath(),u.moveTo(q[q.length-2].x,q[q.length-2].y),u.lineTo(m.x,m.y),u.stroke())},[J,x,i,r]),_=a.useCallback(()=>{if(J&&(g(!1),v.current.length>0&&(k.current.push([...v.current]),v.current=[],I(!1),E.current))){const o=E.current.toDataURL(C);t==null||t(o)}},[J,C,t]),j=a.useCallback(()=>{k.current=[],v.current=[],I(!0),W(),t==null||t(null)},[W,t]),l=a.useCallback(()=>{if(k.current.length!==0&&(k.current.pop(),I(k.current.length===0),W(),E.current)){const o=k.current.length>0?E.current.toDataURL(C):null;t==null||t(o)}},[W,C,t]);return e.jsxs("div",{ref:p,id:L,className:`nice-signature nice-signature--${w} ${M?"nice-signature--disabled":""} ${S?"nice-signature--readonly":""} ${z??""}`,style:K,...G,children:[b&&e.jsx("label",{className:"nice-signature__label",children:b}),e.jsx("div",{className:"nice-signature__canvas-wrap",style:{width:h,height:y},children:e.jsx("canvas",{ref:E,className:"nice-signature__canvas",onMouseDown:c,onMouseMove:H,onMouseUp:_,onMouseLeave:_,onTouchStart:c,onTouchMove:H,onTouchEnd:_,style:{touchAction:"none",cursor:M||S?"default":"crosshair"},"aria-label":b??$("signature.label","Signature pad"),role:"img"})}),(U||A)&&!S&&!M&&e.jsxs("div",{className:"nice-signature__actions",children:[A&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:l,disabled:T,children:$("signature.undo","Undo")}),U&&e.jsx("button",{type:"button",className:"nice-signature__btn",onClick:j,disabled:T,children:$("signature.clear","Clear")})]})]})});vn.displayName="NiceSignaturePad";let Ca=0;function Nt(){return`blk-${++Ca}-${Date.now().toString(36)}`}function Vt(n=""){return{id:Nt(),type:"paragraph",content:n}}function Na(n,t=""){const i={id:Nt(),type:n,content:t};return n==="heading"&&(i.level=2),n==="list"&&(i.listType="unordered"),n==="callout"&&(i.icon="??"),n==="toggle"&&(i.open=!0),i}const wa=[{type:"paragraph",label:"Text",icon:"�",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"H",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"�",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"1.",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"?",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"?",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"??",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"?",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"</>",keywords:"code snippet"},{type:"image",label:"Image",icon:"??",keywords:"image photo picture"},{type:"video",label:"Video",icon:"??",keywords:"video embed"},{type:"table",label:"Table",icon:"?",keywords:"table grid"},{type:"divider",label:"Divider",icon:"-",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"?",keywords:"page break"}];function $a(n){const t=[n.align?`text-align:${n.align}`:"",n.color?`color:${n.color}`:"",n.bgColor?`background-color:${n.bgColor}`:"",n.indent?`margin-left:${n.indent*24}px`:""].filter(Boolean).join(";"),i=t?` style="${t}"`:"",r=(d,h)=>{let y=h;return n.bold&&(y=`<strong>${y}</strong>`),n.italic&&(y=`<em>${y}</em>`),n.underline&&(y=`<u>${y}</u>`),n.strikethrough&&(y=`<s>${y}</s>`),`<${d}${i}>${y}</${d}>`};switch(n.type){case"heading":return r(`h${n.level??2}`,n.content);case"paragraph":return r("p",n.content||" ");case"list":{const d=n.listType==="ordered"?"ol":"ul",h=n.content.split(`
|
|
413
|
+
`).map((y,w)=>{var M;return n.listType==="checklist"?`<li><input type="checkbox" ${((M=n.checked)==null?void 0:M[w])??!1?"checked":""} disabled />${y}</li>`:`<li>${y}</li>`}).join("");return`<${d}${i}>${h}</${d}>`}case"image":return`<figure${i}><img src="${n.src??""}" alt="${n.alt??""}" /></figure>`;case"video":return`<figure${i}><video src="${n.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${n.language??""}">${n.content}</code></pre>`;case"quote":return r("blockquote",n.content);case"callout":return`<div class="nice-doc-callout"${i}><span>${n.icon??"??"}</span><div>${n.content}</div></div>`;case"toggle":return`<details${i}><summary>${n.content.split(`
|
|
414
|
+
`)[0]}</summary>${n.content.split(`
|
|
415
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${i}>${n.content}</table>`;case"embed":return`<iframe src="${n.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return r("p",n.content)}}function Ma(n){let t=0,i=0;for(const r of n){const d=r.content??"";t+=d.length;const h=d.trim().split(/\s+/).filter(Boolean);i+=h.length}return{words:i,chars:t,readingTime:Math.max(1,Math.ceil(i/200))}}const yn=a.forwardRef(({blocks:n,onChange:t,readOnly:i=!1,showToolbar:r=!0,size:d="md",editorSize:h="standard",placeholder:y,onExport:w,onImageUpload:M,maxUndo:S=50,slashCommands:U=!0,showWordCount:A=!1,showToc:b=!1,showFindReplace:C=!0,className:z,style:K,id:X,...G},p)=>{var F,de,xe,Ce,ye,_e,we,Te,De,Le,Ie,Ve,Je,lt,wt,$t;const L=P.nl(X),{t:$}=P.ue(),[E,J]=a.useState(()=>n??[Vt()]),g=n??E,[k,v]=a.useState(0),T=a.useRef(new Map),I=a.useRef(null),[W,x]=a.useState(!1),[c,H]=a.useState(""),[_,j]=a.useState(""),[l,o]=a.useState([]),[m,s]=a.useState(0),[u,q]=a.useState(!1),B=a.useRef([]),V=a.useRef([]),le=a.useCallback(f=>{B.current.push(f.map(Q=>({...Q,checked:Q.checked?[...Q.checked]:void 0}))),B.current.length>S&&B.current.shift(),V.current=[]},[S]),R=a.useCallback(()=>{if(B.current.length===0)return;const f=B.current.pop();V.current.push(g.map(Q=>({...Q}))),n||J(f),t==null||t(f)},[g,n,t]),O=a.useCallback(()=>{if(V.current.length===0)return;const f=V.current.pop();B.current.push(g.map(Q=>({...Q}))),n||J(f),t==null||t(f)},[g,n,t]),[te,oe]=a.useState(!1),[pe,fe]=a.useState(""),[ve,ne]=a.useState(0),re=a.useMemo(()=>{if(!te||!U)return[];const f=pe.toLowerCase();return wa.filter(Q=>Q.label.toLowerCase().includes(f)||Q.keywords.includes(f))},[te,pe,U]),[ce,ge]=a.useState(null),[se,N]=a.useState(null),D=a.useCallback(f=>{le(g);const Q=f(g);n||J(Q),t==null||t(Q)},[g,n,t,le]),Z=a.useCallback((f,Q)=>{D(ee=>ee.map((Ne,Se)=>Se===f?{...Ne,...Q}:Ne))},[D]),he=a.useCallback((f,Q)=>{const ee=Q??Vt();D(Ne=>{const Se=[...Ne];return Se.splice(f+1,0,ee),Se}),v(f+1)},[D]),me=a.useCallback(f=>{const Q={...g[f],id:Nt()};he(f,Q)},[g,he]),ae=a.useCallback(f=>{g.length<=1||(D(Q=>Q.filter((ee,Ne)=>Ne!==f)),v(Math.max(0,f-1)))},[g.length,D]),ie=a.useCallback((f,Q)=>{const ee=f+Q;ee<0||ee>=g.length||(D(Ne=>{const Se=[...Ne];return[Se[f],Se[ee]]=[Se[ee],Se[f]],Se}),v(ee))},[g.length,D]),ke=a.useCallback((f,Q)=>{const ee={type:Q};Q==="heading"&&(ee.level=2),Q==="list"&&(ee.listType="unordered"),Q==="callout"&&(ee.icon="??"),Q==="toggle"&&(ee.open=!0),Z(f,ee)},[Z]),be=a.useCallback(f=>{var ee,Ne;const Q=Na(f.type);f.type==="list"&&f.label.includes("Numbered")&&(Q.listType="ordered"),f.type==="list"&&f.label.includes("Checklist")&&(Q.listType="checklist",Q.checked=[]),((ee=g[k])==null?void 0:ee.content)===""||((Ne=g[k])==null?void 0:Ne.content)==="/"?D(Se=>Se.map((We,Ye)=>Ye===k?{...Q,id:We.id}:We)):he(k,Q),oe(!1),fe("")},[g,k,D,he]),Ee=a.useCallback((f,Q)=>{if(i)return;const ee=g[Q];if(!(ee!=null&&ee.locked)){if((f.ctrlKey||f.metaKey)&&f.key==="z"&&!f.shiftKey){f.preventDefault(),R();return}if((f.ctrlKey||f.metaKey)&&(f.key==="y"||f.key==="z"&&f.shiftKey)){f.preventDefault(),O();return}if((f.ctrlKey||f.metaKey)&&f.key==="d"){f.preventDefault(),me(Q);return}if((f.ctrlKey||f.metaKey)&&f.key==="b"){f.preventDefault(),Z(Q,{bold:!(ee!=null&&ee.bold)});return}if((f.ctrlKey||f.metaKey)&&f.key==="i"){f.preventDefault(),Z(Q,{italic:!(ee!=null&&ee.italic)});return}if((f.ctrlKey||f.metaKey)&&f.key==="u"){f.preventDefault(),Z(Q,{underline:!(ee!=null&&ee.underline)});return}if((f.ctrlKey||f.metaKey)&&f.key==="e"){f.preventDefault(),Z(Q,{strikethrough:!(ee!=null&&ee.strikethrough)});return}if(f.key==="Tab"&&!f.shiftKey){f.preventDefault(),Z(Q,{indent:Math.min(((ee==null?void 0:ee.indent)??0)+1,4)});return}if(f.key==="Tab"&&f.shiftKey){f.preventDefault(),Z(Q,{indent:Math.max(((ee==null?void 0:ee.indent)??0)-1,0)});return}if((f.ctrlKey||f.metaKey)&&f.key==="f"&&C){f.preventDefault(),x(Ne=>!Ne);return}if(te&&re.length>0){if(f.key==="ArrowDown"){f.preventDefault(),ne(Ne=>Math.min(Ne+1,re.length-1));return}if(f.key==="ArrowUp"){f.preventDefault(),ne(Ne=>Math.max(Ne-1,0));return}if(f.key==="Enter"){f.preventDefault(),be(re[ve]);return}if(f.key==="Escape"){oe(!1);return}}f.key==="Enter"&&!f.shiftKey?(f.preventDefault(),he(Q)):f.key==="Backspace"&&g[Q].content===""&&g.length>1?(f.preventDefault(),ae(Q)):f.key==="ArrowUp"&&f.altKey?(f.preventDefault(),ie(Q,-1)):f.key==="ArrowDown"&&f.altKey&&(f.preventDefault(),ie(Q,1))}},[i,g,he,ae,ie,R,O,me,Z,te,re,ve,be,C]),je=a.useCallback((f,Q)=>{const ee=f.target.textContent??"";U&&ee.startsWith("/")?(oe(!0),fe(ee.slice(1)),ne(0)):te&&oe(!1),le(g);const Ne=g.map((Se,We)=>We===Q?{...Se,content:ee}:Se);n||J(Ne),t==null||t(Ne)},[g,n,t,le,U,te]),He=a.useCallback((f,Q)=>{ge(Q),f.dataTransfer.effectAllowed="move"},[]),Oe=a.useCallback((f,Q)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",N(Q)},[]),Ae=a.useCallback((f,Q)=>{if(f.preventDefault(),ce===null||ce===Q){ge(null),N(null);return}D(ee=>{const Ne=[...ee],[Se]=Ne.splice(ce,1);return Ne.splice(Q>ce?Q-1:Q,0,Se),Ne}),v(Q>ce?Q-1:Q),ge(null),N(null)},[ce,D]);a.useEffect(()=>{if(!W||!c){o([]);return}const f=c.toLowerCase(),Q=[];g.forEach((ee,Ne)=>{const Se=(ee.content??"").toLowerCase();let We=0;for(;We<Se.length;){const Ye=Se.indexOf(f,We);if(Ye===-1)break;Q.push({blockIdx:Ne,start:Ye,end:Ye+f.length}),We=Ye+1}}),o(Q),s(0)},[c,W,g]);const Be=a.useCallback(()=>{if(l.length===0)return;const f=(m+1)%l.length;s(f),v(l[f].blockIdx)},[l,m]),Xe=a.useCallback(()=>{if(l.length===0)return;const f=(m-1+l.length)%l.length;s(f),v(l[f].blockIdx)},[l,m]),Qe=a.useCallback(()=>{if(l.length===0||!c)return;const f=l[m],Q=g[f.blockIdx],ee=Q.content.slice(0,f.start),Ne=Q.content.slice(f.end);Z(f.blockIdx,{content:ee+_+Ne})},[l,m,c,_,g,Z]),Ke=a.useCallback(()=>{if(!c)return;const f=c;D(Q=>Q.map(ee=>({...ee,content:ee.content.split(f).join(_)})))},[c,_,D]),Ge=a.useMemo(()=>b?g.map((f,Q)=>f.type==="heading"?{idx:Q,level:f.level??2,text:f.content}:null).filter(Boolean):[],[g,b]),Fe=a.useCallback(async f=>{var ee;const Q=(ee=f.target.files)==null?void 0:ee[0];if(Q){if(M){const Ne=await M(Q);Z(k,{src:Ne})}f.target.value=""}},[M,k,Z]);a.useEffect(()=>{const f=g[k];if(f){const Q=T.current.get(f.id);Q&&Q.focus()}},[k,g]);const Ue=a.useCallback(()=>{const f=g.map($a).join(`
|
|
416
|
+
`);w==null||w(f)},[g,w]),ze=a.useMemo(()=>A?Ma(g):null,[g,A]),[Y,ue]=a.useState(null),$e=a.useCallback((f,Q)=>{i||(f.preventDefault(),ue({x:f.clientX,y:f.clientY,idx:Q}))},[i]);return a.useEffect(()=>{if(!Y)return;const f=()=>ue(null);return window.addEventListener("click",f),()=>window.removeEventListener("click",f)},[Y]),e.jsxs("div",{ref:p,id:L,className:`nice-doc-editor nice-doc-editor--${d} nice-editor--${h} ${i?"nice-doc-editor--readonly":""} ${z??""}`,style:K,role:"application","aria-label":$("docEditor.label","Document Editor"),...G,children:[r&&!i&&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(P.pn,{size:"sm",variant:"ghost",onClick:R,title:$("docEditor.undo","Undo (Ctrl+Z)"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:O,title:$("docEditor.redo","Redo (Ctrl+Y)"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.Ze,{size:"sm",value:((F=g[k])==null?void 0:F.type)??"paragraph",onChange:f=>ke(k,f),label:"",options:[{value:"paragraph",label:$("docEditor.paragraph","Paragraph")},{value:"heading",label:$("docEditor.heading","Heading")},{value:"list",label:$("docEditor.list","List")},{value:"code",label:$("docEditor.code","Code")},{value:"quote",label:$("docEditor.quote","Quote")},{value:"callout",label:$("docEditor.callout","Callout")},{value:"toggle",label:$("docEditor.toggle","Toggle")},{value:"divider",label:$("docEditor.divider","Divider")},{value:"image",label:$("docEditor.image","Image")},{value:"video",label:$("docEditor.video","Video")},{value:"pageBreak",label:$("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),((de=g[k])==null?void 0:de.type)==="heading"&&e.jsx(P.Ze,{size:"sm",value:String(((xe=g[k])==null?void 0:xe.level)??2),onChange:f=>Z(k,{level:Number(f)}),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}}),((Ce=g[k])==null?void 0:Ce.type)==="list"&&e.jsx(P.Ze,{size:"sm",value:((ye=g[k])==null?void 0:ye.listType)??"unordered",onChange:f=>Z(k,{listType:f}),label:"",options:[{value:"unordered",label:"� Bullets"},{value:"ordered",label:"1. Numbers"},{value:"checklist",label:"? Checklist"}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.pn,{size:"sm",variant:(_e=g[k])!=null&&_e.bold?"primary":"ghost",onClick:()=>{var f;return Z(k,{bold:!((f=g[k])!=null&&f.bold)})},title:$("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(P.pn,{size:"sm",variant:(we=g[k])!=null&&we.italic?"primary":"ghost",onClick:()=>{var f;return Z(k,{italic:!((f=g[k])!=null&&f.italic)})},title:$("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(P.pn,{size:"sm",variant:(Te=g[k])!=null&&Te.underline?"primary":"ghost",onClick:()=>{var f;return Z(k,{underline:!((f=g[k])!=null&&f.underline)})},title:$("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(P.pn,{size:"sm",variant:(De=g[k])!=null&&De.strikethrough?"primary":"ghost",onClick:()=>{var f;return Z(k,{strikethrough:!((f=g[k])!=null&&f.strikethrough)})},title:$("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.pn,{size:"sm",variant:((Le=g[k])==null?void 0:Le.align)==="left"?"primary":"ghost",onClick:()=>Z(k,{align:"left"}),title:$("docEditor.alignLeft","Left"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:((Ie=g[k])==null?void 0:Ie.align)==="center"?"primary":"ghost",onClick:()=>Z(k,{align:"center"}),title:$("docEditor.alignCenter","Center"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:((Ve=g[k])==null?void 0:Ve.align)==="right"?"primary":"ghost",onClick:()=>Z(k,{align:"right"}),title:$("docEditor.alignRight","Right"),children:"?"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>{var f;return Z(k,{indent:Math.min((((f=g[k])==null?void 0:f.indent)??0)+1,4)})},title:$("docEditor.indent","Indent (Tab)"),children:"??"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>{var f;return Z(k,{indent:Math.max((((f=g[k])==null?void 0:f.indent)??0)-1,0)})},title:$("docEditor.outdent","Outdent (Shift+Tab)"),children:"??"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.Xe,{size:"sm",label:"",value:((Je=g[k])==null?void 0:Je.color)??"var(--text-primary, #000000)",onChange:f=>Z(k,{color:f}),title:"Text color"}),e.jsx(P.Xe,{size:"sm",label:"",value:((lt=g[k])==null?void 0:lt.bgColor)??"var(--bg-primary, #ffffff)",onChange:f=>Z(k,{bgColor:f}),title:"Block background"}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(P.pn,{size:"sm",variant:(wt=g[k])!=null&&wt.locked?"primary":"ghost",onClick:()=>{var f;return Z(k,{locked:!((f=g[k])!=null&&f.locked)})},title:$("docEditor.lock","Lock/Unlock block"),children:"??"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>me(k),title:$("docEditor.duplicate","Duplicate (Ctrl+D)"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>ae(k),title:$("docEditor.delete","Delete block"),children:"??"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>he(k),title:$("docEditor.addBlock","Add block"),children:"+"}),C&&e.jsx(P.pn,{size:"sm",variant:W?"primary":"ghost",onClick:()=>x(f=>!f),title:$("docEditor.find","Find & Replace (Ctrl+F)"),children:"??"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>q(f=>!f),title:$("docEditor.shortcuts","Keyboard shortcuts"),children:"?"}),w&&e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Ue,children:$("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:I,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:Fe}),W&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-doc-find-bg, #f8f9fa)",borderBottom:"1px solid var(--border-color, #ddd)"},children:[e.jsx(P.Pe,{size:"sm",placeholder:$("docEditor.findPlaceholder","Find..."),value:c,onChange:H,style:{flex:1,maxWidth:200}}),e.jsx(P.Pe,{size:"sm",placeholder:$("docEditor.replacePlaceholder","Replace..."),value:_,onChange:j,style:{flex:1,maxWidth:200}}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Xe,title:$("docEditor.findPrev","Previous"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Be,title:$("docEditor.findNext","Next"),children:"?"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Qe,title:$("docEditor.replaceOne","Replace"),disabled:i,children:$("docEditor.replace","Replace")}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:Ke,title:$("docEditor.replaceAll","Replace all"),disabled:i,children:$("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--text-muted, #666)"},children:l.length>0?`${m+1}/${l.length}`:"0/0"}),e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>x(!1),children:"?"})]}),u&&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:()=>q(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:f=>f.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:$("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",$("docEditor.bold","Bold")],["Ctrl+I",$("docEditor.italic","Italic")],["Ctrl+U",$("docEditor.underline","Underline")],["Ctrl+E",$("docEditor.strikethrough","Strikethrough")],["Ctrl+D",$("docEditor.duplicate","Duplicate block")],["Ctrl+Z",$("docEditor.undo","Undo")],["Ctrl+Y",$("docEditor.redo","Redo")],["Ctrl+F",$("docEditor.find","Find & Replace")],["Enter",$("docEditor.newBlock","New block")],["Backspace",$("docEditor.deleteEmpty","Delete empty block")],["Alt+?",$("docEditor.moveUp","Move block up")],["Alt+?",$("docEditor.moveDown","Move block down")],["Tab",$("docEditor.indent","Indent")],["Shift+Tab",$("docEditor.outdent","Outdent")],["/",$("docEditor.slashCmd","Slash commands")]].map(([f,Q])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:f}),e.jsx("td",{style:{padding:"4px 8px"},children:Q})]},f))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>q(!1),children:$("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[b&&Ge.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--text-muted, #999)"},children:$("docEditor.toc","Contents")}),Ge.map(f=>e.jsx("div",{style:{padding:"3px 8px",paddingLeft:8+(f.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:f.idx===k?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>v(f.idx),title:f.text,children:f.text||$("docEditor.untitled","Untitled")},f.idx))]}),e.jsx("div",{className:"nice-doc-editor__body",style:{flex:1},children:g.map((f,Q)=>e.jsxs("div",{className:`nice-doc-editor__block nice-doc-editor__block--${f.type} ${Q===k?"nice-doc-editor__block--focused":""} ${se===Q?"nice-doc-editor__block--drop-target":""} ${f.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>v(Q),onContextMenu:ee=>$e(ee,Q),draggable:!i&&!f.locked,onDragStart:ee=>He(ee,Q),onDragOver:ee=>Oe(ee,Q),onDrop:ee=>Ae(ee,Q),onDragEnd:()=>{ge(null),N(null)},style:{opacity:ce===Q?.4:1,marginLeft:(f.indent??0)*24},children:[!i&&!f.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:$("docEditor.drag","Drag to reorder"),children:"?"}),f.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:"??"}),f.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):f.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--text-muted, #999)"},children:["� ",$("docEditor.pageBreak","Page Break")," �"]}):f.type==="image"||f.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:f.src?f.type==="image"?e.jsx("img",{src:f.src,alt:f.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:f.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!i&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(P.Pe,{size:"sm",placeholder:$("docEditor.mediaUrl",f.type==="image"?"Image URL":"Video URL"),value:f.src??"",onChange:ee=>Z(Q,{src:ee})}),M&&e.jsx(P.pn,{size:"sm",variant:"ghost",onClick:()=>{var ee;v(Q),(ee=I.current)==null||ee.click()},children:"??"})]})}):f.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:f.bgColor??"#f0f7ff",borderRadius:4,color:f.color},children:[e.jsx("span",{style:{fontSize:"1.2em"},children:f.icon??"??"}),e.jsx("div",{ref:ee=>{ee&&T.current.set(f.id,ee)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:ee=>je(ee,Q),onFocus:()=>v(Q),onKeyDown:ee=>Ee(ee,Q),"data-placeholder":$("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true",style:{flex:1,outline:"none"},children:f.content})]}):f.type==="toggle"?e.jsxs("details",{open:f.open,className:"nice-doc-editor__toggle",onToggle:ee=>Z(Q,{open:ee.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:f.content.split(`
|
|
417
|
+
`)[0]||$("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:ee=>{ee&&T.current.set(f.id,ee)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:ee=>je(ee,Q),onFocus:()=>v(Q),onKeyDown:ee=>Ee(ee,Q),role:"textbox","aria-multiline":"true",style:{padding:"4px 0"},children:f.content.split(`
|
|
418
|
+
`).slice(1).join(`
|
|
419
|
+
`)})]}):f.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!i&&e.jsx(P.Pe,{size:"sm",value:f.language??"",onChange:ee=>Z(Q,{language:ee}),placeholder:"Language",style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:ee=>{ee&&T.current.set(f.id,ee)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,onInput:ee=>je(ee,Q),onFocus:()=>v(Q),onKeyDown:ee=>Ee(ee,Q),role:"textbox","aria-multiline":"true",style:{fontFamily:"monospace",background:"var(--bg-elevated, #1e1e1e)",color:"var(--text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:f.content})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:ee=>{ee&&T.current.set(f.id,ee)},className:"nice-doc-editor__content",contentEditable:!i&&!f.locked,suppressContentEditableWarning:!0,style:{textAlign:f.align,fontWeight:f.bold?"bold":void 0,fontStyle:f.italic?"italic":void 0,textDecoration:[f.underline?"underline":"",f.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:f.color,backgroundColor:f.bgColor},onInput:ee=>je(ee,Q),onFocus:()=>v(Q),onKeyDown:ee=>Ee(ee,Q),"data-placeholder":!f.content&&y?y:void 0,role:"textbox","aria-multiline":"true",children:f.content}),te&&Q===k&&re.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:re.map((ee,Ne)=>e.jsxs("li",{className:Ne===ve?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:Ne===ve?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Se=>{Se.preventDefault(),be(ee)},onMouseEnter:()=>ne(Ne),children:[e.jsx("span",{style:{width:24,textAlign:"center"},children:ee.icon}),e.jsx("span",{children:ee.label})]},`${ee.type}-${ee.label}`))})]})]},f.id))})]}),Y&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:Y.x,top:Y.y,zIndex:1e3,background:"var(--bg-primary, #fff)",border:"1px solid var(--border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{me(Y.idx),ue(null)},children:"? Duplicate"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{he(Y.idx),ue(null)},children:"+ Insert below"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ie(Y.idx,-1),ue(null)},children:"? Move up"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{ie(Y.idx,1),ue(null)},children:"? Move down"}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{var f;Z(Y.idx,{locked:!((f=g[Y.idx])!=null&&f.locked)}),ue(null)},children:($t=g[Y.idx])!=null&&$t.locked?"?? Unlock":"?? Lock"}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--border-color, #eee)"}}),e.jsx("div",{style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{ae(Y.idx),ue(null)},children:"?? Delete"})]}),A&&ze&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--text-muted, #666)",borderTop:"1px solid var(--border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[ze.words," ",$("docEditor.words","words")]}),e.jsxs("span",{children:[ze.chars," ",$("docEditor.chars","characters")]}),e.jsxs("span",{children:[g.length," ",$("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",ze.readingTime," ",$("docEditor.readingTime","min read")]})]})]})});yn.displayName="NiceDocumentEditor";const Sa=["street","streetNumber","apartment","city","postalCode","state","country"],ot={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},_n=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b={},onChange:C,fields:z=Sa,placeholders:K={},countries:X,layout:G="vertical",countryFirst:p=!1,validatePostalCode:L},$)=>{const E=P.Cl(A,M),J=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=P.ue(),k=P.nl(M),v=a.useCallback((x,c)=>{C==null||C({...b,[x]:c})},[b,C]),T=a.useMemo(()=>{if(L&&b.postalCode)return L(b.postalCode,b.country)},[L,b.postalCode,b.country]),I=a.useMemo(()=>p&&z.includes("country")?["country",...z.filter(x=>x!=="country")]:z,[z,p]),W=`nice-address nice-address--${G} nice-size-${y}`;return J?null:e.jsxs("div",{ref:$,id:k,className:`${W}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,role:"group","aria-label":n??g("address","Address"),children:[n&&e.jsxs("label",{className:"nice-address__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:I.map(x=>x==="country"&&X?e.jsxs("div",{className:`nice-address__field nice-address__field--${x}`,children:[e.jsx("label",{className:"nice-address__field-label",children:g(x,ot[x])}),e.jsxs("select",{className:"nice-input nice-select",value:b.country??"",onChange:c=>v("country",c.target.value),disabled:d,"aria-label":g(x,ot[x]),children:[e.jsx("option",{value:"",children:K.country??g("selectCountry","— Select country —")}),X.map(c=>e.jsx("option",{value:c.code,children:c.name},c.code))]})]},x):e.jsxs("div",{className:`nice-address__field nice-address__field--${x}`,children:[e.jsx("label",{className:"nice-address__field-label",children:g(x,ot[x])}),e.jsx("input",{className:`nice-input${x==="postalCode"&&T?" nice-input--error":""}`,type:"text",name:w?`${w}.${x}`:x,value:b[x]??"",onChange:c=>v(x,c.target.value),placeholder:K[x]??"",disabled:d,readOnly:h,"aria-label":g(x,ot[x])}),x==="postalCode"&&T&&e.jsx("span",{className:"nice-error-text",children:T})]},x))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});_n.displayName="NiceAddressInput";const Ea=[{code:"PLN",symbol:"zł",name:"Polish Zloty"},{code:"EUR",symbol:"€",name:"Euro"},{code:"USD",symbol:"$",name:"US Dollar"},{code:"GBP",symbol:"£",name:"British Pound"},{code:"CZK",symbol:"Kč",name:"Czech Koruna"},{code:"CHF",symbol:"Fr",name:"Swiss Franc"}],kn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b,onChange:C,onBlur:z,currency:K="PLN",onCurrencyChange:X,currencies:G=Ea,useMinorUnit:p=!1,min:L,max:$,locale:E,placeholder:J,showCurrencySelector:g},k)=>{const v=P.Cl(A,M),T=v==="hidden";v==="disabled"&&(d=!0),v==="readOnly"&&(h=!0);const{t:I}=P.ue(),W=P.nl(M),x=a.useMemo(()=>G.find(o=>o.code===K)??G[0],[K,G]),c=(x==null?void 0:x.decimals)??2,H=a.useMemo(()=>b==null?"":(p?b/Math.pow(10,c):b).toFixed(c),[b,p,c]),_=a.useCallback(o=>{const m=o.replace(/[^\d.,\-]/g,"").replace(",",".");if(m===""||m==="-"){C==null||C(null);return}const s=parseFloat(m);if(isNaN(s))return;const u=p?Math.round(s*Math.pow(10,c)):s;L!=null&&u<L||$!=null&&u>$||(C==null||C(u))},[C,p,c,L,$]),j=g??G.length>1,l=a.useMemo(()=>{if(b==null)return"";const o=p?b/Math.pow(10,c):b;try{return new Intl.NumberFormat(E,{style:"currency",currency:(x==null?void 0:x.code)??"USD",minimumFractionDigits:c}).format(o)}catch{return`${o.toFixed(c)} ${x==null?void 0:x.code}`}},[b,p,c,E,x]);return T?null:e.jsxs("div",{ref:k,id:W,className:`nice-currency nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-currency__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-currency__row",children:[j&&e.jsx("select",{className:"nice-currency__select nice-select",value:K,onChange:o=>X==null?void 0:X(o.target.value),disabled:d,"aria-label":I("currency","Currency"),children:G.map(o=>e.jsxs("option",{value:o.code,children:[o.symbol," ",o.code]},o.code))}),!j&&e.jsx("span",{className:"nice-currency__symbol",children:x==null?void 0:x.symbol}),e.jsx("input",{className:"nice-input nice-currency__amount",type:"text",inputMode:"decimal",name:w,value:H,onChange:o=>_(o.target.value),onBlur:z,placeholder:J??`0.${"0".repeat(c)}`,disabled:d,readOnly:h,"aria-label":I("amount","Amount")})]}),l&&b!=null&&e.jsx("span",{className:"nice-currency__formatted",children:l}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});kn.displayName="NiceCurrencyInput";let Ta=1;function Da(n){return{id:`new-${Ta++}`,description:"",quantity:1,unitPrice:0,vatRate:n,discount:0,unit:"szt."}}function jn(n){const t=n.quantity*n.unitPrice*(1-(n.discount??0)/100),i=Math.round(t*100)/100,r=Math.round(i*(n.vatRate??0)/100*100)/100;return{...n,netAmount:i,grossAmount:i+r}}function Ra(n){const t=n.map(jn),i=t.reduce((w,M)=>w+(M.netAmount??0),0),r=t.reduce((w,M)=>w+(M.grossAmount??0),0),d=r-i,h=new Map;for(const w of t){const M=w.vatRate??0,S=h.get(M)??{base:0,amount:0};S.base+=w.netAmount??0,S.amount+=(w.grossAmount??0)-(w.netAmount??0),h.set(M,S)}const y=Array.from(h.entries()).map(([w,M])=>({rate:w,base:Math.round(M.base*100)/100,amount:Math.round(M.amount*100)/100}));return{totalNet:Math.round(i*100)/100,totalVat:Math.round(d*100)/100,totalGross:Math.round(r*100)/100,vatBreakdown:y}}const Cn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b=[],onChange:C,onTotalsChange:z,currencySymbol:K="zł",defaultVatRate:X=23,vatRates:G=[0,5,8,23],units:p=["szt.","h","kg","m","usł."],showDiscount:L=!0,showUnit:$=!0,showTotals:E=!0,editable:J=!0,maxLines:g},k)=>{const v=P.Cl(A,M),T=v==="hidden";v==="disabled"&&(d=!0),v==="readOnly"&&(h=!0);const{t:I}=P.ue(),W=P.nl(M),x=a.useMemo(()=>b.map(jn),[b]),c=a.useMemo(()=>Ra(b),[b]);a.useEffect(()=>{z==null||z(c)},[c,z]);const H=a.useCallback((o,m,s)=>{const u=[...b];u[o]={...u[o],[m]:s},C==null||C(u)},[b,C]),_=a.useCallback(()=>{g&&b.length>=g||(C==null||C([...b,Da(X)]))},[b,C,X,g]),j=a.useCallback(o=>{C==null||C(b.filter((m,s)=>s!==o))},[b,C]),l=o=>`${o.toFixed(2)} ${K}`;return T?null:e.jsxs("div",{ref:k,id:W,className:`nice-invoice-lines nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("table",{className:"nice-invoice-lines__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-il__th-num",children:"#"}),e.jsx("th",{className:"nice-il__th-desc",children:I("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:I("qty","Qty")}),$&&e.jsx("th",{className:"nice-il__th-unit",children:I("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:I("unitPrice","Unit Price")}),L&&e.jsx("th",{className:"nice-il__th-disc",children:I("discount","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:I("vat","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:I("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:I("gross","Gross")}),J&&!h&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:x.map((o,m)=>e.jsxs("tr",{children:[e.jsx("td",{className:"nice-il__cell-num",children:m+1}),e.jsx("td",{className:"nice-il__cell-desc",children:e.jsx("input",{className:"nice-input",type:"text",value:o.description,onChange:s=>H(m,"description",s.target.value),disabled:d,readOnly:h,placeholder:I("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:o.quantity,onChange:s=>H(m,"quantity",parseFloat(s.target.value)||0),disabled:d,readOnly:h,min:0,step:"any"})}),$&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:o.unit??"",onChange:s=>H(m,"unit",s.target.value),disabled:d,children:p.map(s=>e.jsx("option",{value:s,children:s},s))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:o.unitPrice,onChange:s=>H(m,"unitPrice",parseFloat(s.target.value)||0),disabled:d,readOnly:h,min:0,step:"0.01"})}),L&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:o.discount??0,onChange:s=>H(m,"discount",parseFloat(s.target.value)||0),disabled:d,readOnly:h,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:o.vatRate??0,onChange:s=>H(m,"vatRate",parseInt(s.target.value,10)),disabled:d,children:G.map(s=>e.jsxs("option",{value:s,children:[s,"%"]},s))})}),e.jsx("td",{className:"nice-il__cell-net",children:l(o.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:l(o.grossAmount??0)}),J&&!h&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>j(m),disabled:d,title:I("remove","Remove"),children:"✕"})})]},o.id))})]}),J&&!h&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:_,disabled:d||g!=null&&b.length>=g,children:["+ ",I("addLine","Add line")]}),E&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[I("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:l(c.totalNet)})]}),c.vatBreakdown.map(o=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsxs("span",{children:["VAT ",o.rate,"%:"]}),e.jsx("span",{className:"nice-il__total-value",children:l(o.amount)})]},o.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[I("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:l(c.totalGross)})]})]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Cn.displayName="NiceInvoiceLineEditor";const Nn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b=[],onChange:C,contacts:z=[],onSearch:K,searchDelay:X=300,multiple:G=!1,placeholder:p,onContactClick:L,maxSelections:$},E)=>{const J=P.Cl(A,M),g=J==="hidden";J==="disabled"&&(d=!0),J==="readOnly"&&(h=!0);const{t:k}=P.ue(),v=P.nl(M),[T,I]=a.useState(""),[W,x]=a.useState([]),[c,H]=a.useState(!1),[_,j]=a.useState(!1),l=a.useMemo(()=>{const u=[...z,...W],q=new Map(u.map(B=>[B.id,B]));return b.map(B=>q.get(B)).filter(Boolean)},[b,z,W]),o=a.useCallback(u=>{if(I(u),u.length<1){x([]),H(!1);return}if(K){j(!0);const V=setTimeout(async()=>{const le=await K(u);x(le),H(!0),j(!1)},X);return()=>clearTimeout(V)}const q=u.toLowerCase(),B=z.filter(V=>{var le,R;return V.name.toLowerCase().includes(q)||((le=V.email)==null?void 0:le.toLowerCase().includes(q))||((R=V.phone)==null?void 0:R.includes(u))});x(B),H(!0)},[K,z,X]),m=a.useCallback(u=>{if(G)if(b.includes(u.id))C==null||C(b.filter(q=>q!==u.id));else{if($&&b.length>=$)return;C==null||C([...b,u.id])}else C==null||C([u.id]),H(!1),I("")},[b,C,G,$]),s=a.useCallback(u=>{C==null||C(b.filter(q=>q!==u))},[b,C]);return g?null:e.jsxs("div",{ref:E,id:v,className:`nice-contact-picker nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-contact-picker__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),l.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:l.map(u=>e.jsxs("span",{className:"nice-contact-picker__chip",onClick:()=>L==null?void 0:L(u),children:[u.avatarUrl&&e.jsx("img",{src:u.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:u.name}),!h&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:q=>{q.stopPropagation(),s(u.id)},disabled:d,children:"×"})]},u.id))}),!h&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{className:"nice-input",type:"text",value:T,onChange:u=>o(u.target.value),onFocus:()=>T.length>0&&H(!0),onBlur:()=>setTimeout(()=>H(!1),200),placeholder:p??k("searchContacts","Search contacts…"),disabled:d,"aria-label":k("searchContacts","Search contacts")}),_&&e.jsx("span",{className:"nice-contact-picker__spinner",children:"⏳"})]}),c&&W.length>0&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",children:W.map(u=>e.jsxs("div",{className:`nice-contact-picker__option${b.includes(u.id)?" nice-contact-picker__option--selected":""}`,role:"option","aria-selected":b.includes(u.id),onClick:()=>m(u),children:[u.avatarUrl&&e.jsx("img",{src:u.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:u.name}),u.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:u.subtitle}),u.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:u.email})]}),u.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:u.type==="person"?"👤":"🏢"})]},u.id))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Nn.displayName="NiceContactPicker";const La=["highlight","underline","strikethrough","freehand","text","rect","arrow"],Ia={highlight:"🖍️",underline:"⎁",strikethrough:"S̶",freehand:"✏️",text:"T",rect:"▭",arrow:"→",stamp:"🔏"},wn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:w,className:M,style:S,accessMode:U,src:A,annotations:b=[],onAnnotationsChange:C,activeTool:z,onToolChange:K,currentPage:X=1,onPageChange:G,totalPages:p=1,defaultColor:L="var(--nice-warning, #ffff00)",tools:$=La,author:E,zoom:J=1,onZoomChange:g,onAnnotationClick:k,onAnnotationDelete:v},T)=>{const I=P.Cl(U,w),W=I==="hidden";I==="disabled"&&(d=!0),I==="readOnly"&&(h=!0);const{t:x}=P.ue(),c=P.nl(w),H=b.filter(l=>l.page===X),_=a.useCallback(l=>{K==null||K(z===l?null:l)},[z,K]),j=a.useCallback(l=>{if(h||!z||z==="freehand")return;const o=l.currentTarget.getBoundingClientRect(),m=(l.clientX-o.left)/o.width,s=(l.clientY-o.top)/o.height,u={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:z,page:X,x:m,y:s,color:L,author:E,createdAt:new Date().toISOString(),text:z==="text"?"":void 0};C==null||C([...b,u])},[h,z,X,L,E,b,C]);return W?null:e.jsxs("div",{ref:T,id:c,className:`nice-pdf-annotation nice-size-${y}${M?` ${M}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("div",{className:"nice-pdf-annotation__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),!h&&e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[$.map(l=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${z===l?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>_(l),disabled:d,title:x(`pdfTool_${l}`,l),children:Ia[l]},l)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:d,onClick:()=>g==null?void 0:g(Math.max(.25,J-.25)),title:x("zoomOut","Zoom out"),children:"−"}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(J*100),"%"]}),e.jsx("button",{type:"button",disabled:d,onClick:()=>g==null?void 0:g(Math.min(4,J+.25)),title:x("zoomIn","Zoom in"),children:"+"})]}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${J})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:A,className:"nice-pdf-annotation__frame",title:x("pdfViewer","PDF Viewer")}),e.jsx("div",{className:"nice-pdf-annotation__layer",onClick:j,children:H.map(l=>e.jsxs("div",{className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${l.tool}`,style:{left:`${l.x*100}%`,top:`${l.y*100}%`,backgroundColor:l.color},onClick:o=>{o.stopPropagation(),k==null||k(l)},title:l.text??l.tool,children:[l.text&&e.jsx("span",{children:l.text}),!h&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:o=>{o.stopPropagation(),v==null||v(l.id)},children:"×"})]},l.id))})]}),e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:d||X<=1,onClick:()=>G==null?void 0:G(X-1),children:"◀"}),e.jsx("span",{children:x("pageOf","{page} / {total}").replace("{page}",String(X)).replace("{total}",String(p))}),e.jsx("button",{type:"button",disabled:d||X>=p,onClick:()=>G==null?void 0:G(X+1),children:"▶"})]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});wn.displayName="NicePDFAnnotationEditor";const $n=a.forwardRef(({label:n,helperText:t,error:i,disabled:r,readOnly:d,size:h="md",id:y,className:w,style:M,accessMode:S,pages:U,selectedPageId:A,content:b="",contentFormat:C="html",editing:z=!1,onPageSelect:K,onContentChange:X,onSave:G,onCreatePage:p,onDeletePage:L,onEditToggle:$,onVersionHistory:E,sidebarWidth:J=260,sidebarCollapsed:g=!1,onSidebarToggle:k,searchable:v=!0,onSearch:T},I)=>{const W=P.Cl(S,y),x=W==="hidden";W==="disabled"&&(r=!0),W==="readOnly"&&(d=!0);const{t:c}=P.ue(),H=P.nl(y),[_,j]=a.useState(""),[l,o]=a.useState(""),[m,s]=a.useState(!1),u=a.useMemo(()=>{const le=R=>{for(const O of R){if(O.id===A)return O;if(O.children){const te=le(O.children);if(te)return te}}};return le(U)},[U,A]),q=a.useCallback(le=>{j(le),T==null||T(le)},[T]),B=a.useCallback(()=>{l.trim()&&(p==null||p(A??null,l.trim()),o(""),s(!1))},[l,A,p]),V=(le,R=0)=>e.jsx("ul",{className:"nice-wiki__tree",style:{paddingLeft:R>0?16:0},children:le.map(O=>{var te;return e.jsxs("li",{className:"nice-wiki__tree-item",children:[e.jsxs("div",{className:`nice-wiki__tree-node${O.id===A?" nice-wiki__tree-node--active":""}${O.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>K==null?void 0:K(O),role:"treeitem","aria-selected":O.id===A,children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:(te=O.children)!=null&&te.length?"📁":"📄"}),e.jsx("span",{className:"nice-wiki__tree-title",children:O.title}),O.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:c("draft","Draft")})]}),O.children&&O.children.length>0&&V(O.children,R+1)]},O.id)})});return x?null:e.jsxs("div",{ref:I,id:H,className:`nice-wiki nice-size-${h}${w?` ${w}`:""}${r?" nice-disabled":""}`,style:M,children:[!g&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:J},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:n??c("wiki","Wiki")}),k&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>k(!0),children:"«"})]}),v&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:_,onChange:le=>q(le.target.value),placeholder:c("searchPages","Search pages…"),disabled:r}),e.jsx("div",{className:"nice-wiki__page-tree",role:"tree",children:V(U)}),p&&!d&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:m?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:l,onChange:le=>o(le.target.value),placeholder:c("pageTitle","Page title"),onKeyDown:le=>le.key==="Enter"&&B(),disabled:r}),e.jsx("button",{type:"button",disabled:r||!l.trim(),onClick:B,children:"✓"}),e.jsx("button",{type:"button",onClick:()=>s(!1),children:"✕"})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>s(!0),disabled:r,children:["+ ",c("newPage","New page")]})})]}),g&&k&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>k(!1),children:"»"}),e.jsx("main",{className:"nice-wiki__content",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:u.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[$&&!d&&e.jsx("button",{type:"button",disabled:r,onClick:()=>$(!z),children:z?c("preview","Preview"):c("edit","Edit")}),E&&e.jsx("button",{type:"button",disabled:r,onClick:()=>E(u.id),children:c("history","History")}),L&&!d&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:r,onClick:()=>L(u.id),children:c("delete","Delete")})]})]}),u.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[u.updatedBy&&e.jsxs("span",{children:[c("lastEditedBy","Last edited by")," ",u.updatedBy]}),e.jsx("span",{children:new Date(u.updatedAt).toLocaleDateString()})]}),z?e.jsxs("div",{className:"nice-wiki__editor",children:[e.jsx("textarea",{className:"nice-wiki__editor-textarea",value:b,onChange:le=>X==null?void 0:X(le.target.value),disabled:r}),G&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:r,onClick:()=>G(u.id,b),children:c("save","Save")})]}):e.jsx("div",{className:"nice-wiki__viewer",children:C==="html"?e.jsx("div",{className:"nice-wiki__html",dangerouslySetInnerHTML:{__html:P.Ys(b)}}):e.jsx("pre",{className:"nice-wiki__markdown",children:b})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:c("selectPage","Select a page from the sidebar or create a new one.")})})}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});$n.displayName="NiceWiki";const Aa=[{code:"PL",label:"Polska",prefix:"PL",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"DE",label:"Deutschland",prefix:"DE",pattern:/^\d{9}$/,placeholder:"123456789"},{code:"GB",label:"United Kingdom",prefix:"GB",pattern:/^\d{9}(\d{3})?$/,placeholder:"123456789"},{code:"FR",label:"France",prefix:"FR",pattern:/^[A-Z0-9]{2}\d{9}$/,placeholder:"XX123456789"},{code:"CZ",label:"Česko",prefix:"CZ",pattern:/^\d{8,10}$/,placeholder:"12345678"},{code:"SK",label:"Slovensko",prefix:"SK",pattern:/^\d{10}$/,placeholder:"1234567890"},{code:"IT",label:"Italia",prefix:"IT",pattern:/^\d{11}$/,placeholder:"12345678901"},{code:"ES",label:"España",prefix:"ES",pattern:/^[A-Z0-9]\d{7}[A-Z0-9]$/,placeholder:"X1234567X"}],Mn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b="",onChange:C,countryCode:z="PL",onCountryChange:K,countries:X=Aa,showCountrySelector:G=!0,autoPrefixVat:p=!0,validationResult:L,onValidateRequest:$,placeholder:E},J)=>{const g=P.Cl(A,M),k=g==="hidden";g==="disabled"&&(d=!0),g==="readOnly"&&(h=!0);const{t:v}=P.ue(),T=P.nl(M),I=a.useMemo(()=>X.find(_=>_.code===z)??X[0],[X,z]),W=a.useCallback(_=>{let j=_.toUpperCase();return I&&j.startsWith(I.prefix)&&(j=j.slice(I.prefix.length)),I?I.pattern.test(j):j.length>0},[I]),x=a.useCallback(_=>{const j=_.target.value.replace(/\s/g,"");C==null||C(j,W(j))},[C,W]),c=p&&b&&I&&!b.toUpperCase().startsWith(I.prefix)?`${I.prefix}${b}`:b,H=W(b);return k?null:e.jsxs("div",{ref:J,id:T,className:`nice-vat-input nice-size-${y}${S?` ${S}`:""}${i||!H&&b.length>0?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-vat-input__label",htmlFor:`${T}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-vat-input__row",children:[G&&e.jsx("select",{className:"nice-vat-input__country",value:z,onChange:_=>K==null?void 0:K(_.target.value),disabled:d||h,children:X.map(_=>e.jsx("option",{value:_.code,children:_.prefix},_.code))}),e.jsx("input",{id:`${T}-input`,className:"nice-input nice-vat-input__field",type:"text",name:w,value:b,onChange:x,readOnly:h,disabled:d,placeholder:E??(I==null?void 0:I.placeholder),required:r,"aria-invalid":!H&&b.length>0}),$&&b.length>0&&e.jsx("button",{type:"button",className:"nice-vat-input__verify",disabled:d||!H,onClick:()=>$(p?c:b,z),title:v("verifyVat","Verify VAT number"),children:"🔍"})]}),L&&e.jsxs("div",{className:`nice-vat-input__result nice-vat-input__result--${L.valid?"valid":"invalid"}`,children:[L.valid?"✅":"❌"," ",L.companyName??L.error??(L.valid?v("vatValid","VAT number valid"):v("vatInvalid","VAT number invalid"))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Mn.displayName="NiceVatInput";const za=[{id:"pl-23",label:"23%",rate:.23,countryCode:"PL",category:"standard",isDefault:!0},{id:"pl-8",label:"8%",rate:.08,countryCode:"PL",category:"reduced"},{id:"pl-5",label:"5%",rate:.05,countryCode:"PL",category:"reduced"},{id:"pl-0",label:"0%",rate:0,countryCode:"PL",category:"zero"},{id:"pl-zw",label:"zw.",rate:0,countryCode:"PL",category:"exempt"},{id:"pl-np",label:"n.p.",rate:0,countryCode:"PL",category:"exempt"}],Sn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b,onChange:C,rates:z,countryCode:K,placeholder:X,showPercentage:G=!0},p)=>{const L=P.Cl(A,M),$=L==="hidden";L==="disabled"&&(d=!0),L==="readOnly"&&(h=!0);const{t:E}=P.ue(),J=P.nl(M),g=a.useMemo(()=>{const v=z??za;return K?v.filter(T=>!T.countryCode||T.countryCode===K):v},[z,K]),k=a.useCallback(v=>{const T=v.target.value,I=g.find(W=>W.id===T);I&&(C==null||C(T,I))},[C,g]);return $?null:e.jsxs("div",{ref:p,id:J,className:`nice-tax-rate nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-tax-rate__label",htmlFor:`${J}-select`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("select",{id:`${J}-select`,className:"nice-select nice-tax-rate__select",name:w,value:b??"",onChange:k,disabled:d||h,required:r,children:[e.jsx("option",{value:"",disabled:!0,children:X??E("selectRate","Select rate…")}),g.map(v=>e.jsxs("option",{value:v.id,children:[v.label,G&&v.category!=="exempt"?` (${(v.rate*100).toFixed(0)}%)`:""]},v.id))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Sn.displayName="NiceTaxRatePicker";const Pa={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)"},En=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",name:w,id:M,className:S,style:U,accessMode:A,value:b,onChange:C,accounts:z,treeView:K=!1,placeholder:X,searchable:G=!0,showType:p=!0,onSearch:L},$)=>{const E=P.Cl(A,M),J=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=P.ue(),k=P.nl(M),[v,T]=a.useState(""),[I,W]=a.useState(!1),x=a.useMemo(()=>{const l=o=>{for(const m of o){if(m.code===b)return m;if(m.children){const s=l(m.children);if(s)return s}}};return l(z)},[z,b]),c=a.useMemo(()=>{const l=[],o=m=>{for(const s of m)l.push(s),s.children&&o(s.children)};return o(z),l},[z]),H=a.useMemo(()=>{if(!v)return c;const l=v.toLowerCase();return c.filter(o=>o.code.toLowerCase().includes(l)||o.name.toLowerCase().includes(l))},[c,v]),_=a.useCallback(l=>{T(l),L==null||L(l),W(!0)},[L]),j=a.useCallback(l=>{C==null||C(l.code,l),W(!1),T("")},[C]);return J?null:e.jsxs("div",{ref:$,id:k,className:`nice-account-picker nice-size-${y}${S?` ${S}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:U,children:[n&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${k}-input`,children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:G&&!h?e.jsx("input",{id:`${k}-input`,className:"nice-input",type:"text",value:I?v:x?`${x.code} — ${x.name}`:"",onChange:l=>_(l.target.value),onFocus:()=>{T(""),W(!0)},onBlur:()=>setTimeout(()=>W(!1),200),placeholder:X??g("searchAccount","Search account…"),disabled:d,required:r}):e.jsx("div",{className:"nice-account-picker__display",children:x?`${x.code} — ${x.name}`:X??g("selectAccount","Select account…")})}),I&&H.length>0&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",children:H.map(l=>e.jsxs("div",{className:`nice-account-picker__option${l.code===b?" nice-account-picker__option--selected":""}${l.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":l.code===b,onClick:()=>j(l),children:[p&&l.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Pa[l.type]},title:l.type,children:"●"}),e.jsx("span",{className:"nice-account-picker__code",children:l.code}),e.jsx("span",{className:"nice-account-picker__name",children:l.name})]},l.code))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});En.displayName="NiceAccountPicker";const Tn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:w,className:M,style:S,accessMode:U,mode:A="manual",onScan:b,onModeChange:C,beepOnScan:z=!0,beepFrequency:K=1800,beepDuration:X=150,placeholder:G,scanHistory:p=[],showHistory:L=!0,maxHistory:$=10,autoFocus:E=!0,onCameraFrame:J},g)=>{const k=P.Cl(U,w),v=k==="hidden";k==="disabled"&&(d=!0),k==="readOnly"&&(h=!0);const{t:T}=P.ue(),I=P.nl(w),[W,x]=a.useState(""),c=a.useRef(null),H=a.useRef(null),_=a.useCallback(()=>{if(z)try{H.current||(H.current=new AudioContext);const o=H.current,m=o.createOscillator(),s=o.createGain();m.connect(s),s.connect(o.destination),m.frequency.value=K,m.type="square",s.gain.value=.3,m.start(),m.stop(o.currentTime+X/1e3)}catch{}},[z,K,X]),j=a.useCallback(()=>{var o;W.trim()&&(_(),b==null||b({value:W.trim(),format:"manual",scannedAt:new Date}),x(""),(o=c.current)==null||o.focus())},[W,b,_]),l=p.slice(0,$);return v?null:e.jsxs("div",{ref:g,id:I,className:`nice-scanner nice-size-${y}${M?` ${M}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("div",{className:"nice-scanner__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsxs("div",{className:"nice-scanner__modes",children:[e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${A==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>C==null?void 0:C("camera"),disabled:d,children:["📷 ",T("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${A==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>C==null?void 0:C("manual"),disabled:d,children:["⌨️ ",T("manual","Manual")]})]}),A==="camera"&&e.jsx("div",{className:"nice-scanner__camera",children:e.jsx("div",{className:"nice-scanner__viewfinder",children:e.jsxs("div",{className:"nice-scanner__viewfinder-overlay",children:[e.jsx("span",{children:"📷"}),e.jsx("p",{children:T("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),A==="manual"&&!h&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:c,className:"nice-input nice-scanner__input",type:"text",value:W,onChange:o=>x(o.target.value),onKeyDown:o=>o.key==="Enter"&&j(),placeholder:G??T("enterCode","Enter or scan code…"),disabled:d,autoFocus:E}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:j,disabled:d||!W.trim(),children:"✓"})]}),L&&l.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:T("recentScans","Recent scans")}),l.map((o,m)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:o.value}),o.format&&e.jsx("span",{className:"nice-scanner__history-format",children:o.format}),e.jsx("span",{className:"nice-scanner__history-time",children:o.scannedAt.toLocaleTimeString()})]},m))]}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Tn.displayName="NiceScannerControl";const Dn=a.forwardRef(({label:n,helperText:t,error:i,required:r,disabled:d,readOnly:h,size:y="md",id:w,className:M,style:S,accessMode:U,value:A="",onChange:b,onComplete:C,length:z=4,masked:K=!0,showKeypad:X=!1,autoSubmit:G=!0,shake:p=!1,placeholderChar:L="·"},$)=>{const E=P.Cl(U,w),J=E==="hidden";E==="disabled"&&(d=!0),E==="readOnly"&&(h=!0);const{t:g}=P.ue(),k=P.nl(w),v=a.useRef([]),[T,I]=a.useState(!1);a.useEffect(()=>{if(p){I(!0);const _=setTimeout(()=>I(!1),500);return()=>clearTimeout(_)}},[p]);const W=A.split("").slice(0,z);for(;W.length<z;)W.push("");const x=a.useCallback((_,j)=>{var m;const l=[...W];l[_]=j;const o=l.join("");b==null||b(o),j&&_<z-1&&((m=v.current[_+1])==null||m.focus()),G&&o.length===z&&o.indexOf("")===-1&&(C==null||C(o))},[W,z,b,C,G]),c=a.useCallback((_,j)=>{var l,o,m;_.key==="Backspace"&&!W[j]&&j>0&&((l=v.current[j-1])==null||l.focus(),x(j-1,"")),_.key==="ArrowLeft"&&j>0&&((o=v.current[j-1])==null||o.focus()),_.key==="ArrowRight"&&j<z-1&&((m=v.current[j+1])==null||m.focus())},[W,z,x]),H=a.useCallback(_=>{var j,l,o;if(_==="clear"){b==null||b(""),(j=v.current[0])==null||j.focus();return}if(_==="backspace"){const m=A.slice(0,-1);b==null||b(m);const s=Math.max(0,m.length-1);(l=v.current[s])==null||l.focus();return}if(A.length<z){const m=A+_;b==null||b(m),m.length<z&&((o=v.current[m.length])==null||o.focus()),G&&m.length===z&&(C==null||C(m))}},[A,z,b,C,G]);return J?null:e.jsxs("div",{ref:$,id:k,className:`nice-pin nice-size-${y}${T?" nice-pin--shake":""}${M?` ${M}`:""}${i?" nice-error":""}${d?" nice-disabled":""}`,style:S,children:[n&&e.jsxs("label",{className:"nice-pin__label",children:[n,r&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-pin__boxes",children:W.map((_,j)=>e.jsx("input",{ref:l=>{v.current[j]=l},className:"nice-pin__box",type:K?"password":"text",inputMode:"numeric",maxLength:1,value:_,onChange:l=>{const o=l.target.value.replace(/\D/g,"");o.length<=1&&x(j,o)},onKeyDown:l=>c(l,j),disabled:d,readOnly:h,placeholder:L,"aria-label":`${g("digit","Digit")} ${j+1}`},j))}),X&&!h&&e.jsx("div",{className:"nice-pin__keypad",children:["1","2","3","4","5","6","7","8","9","clear","0","backspace"].map(_=>e.jsx("button",{type:"button",className:`nice-pin__key${_==="clear"||_==="backspace"?" nice-pin__key--action":""}`,onClick:()=>H(_),disabled:d,children:_==="clear"?"C":_==="backspace"?"⌫":_},_))}),t&&e.jsx("span",{className:"nice-helper-text",children:t}),i&&typeof i=="string"&&e.jsx("span",{className:"nice-error-text",children:i})]})});Dn.displayName="NicePinCodeInput";exports.$=Xt;exports.A=Dn;exports.B=Zn;exports.C=Tn;exports.E=vn;exports.F=Sn;exports.G=un;exports.H=Mn;exports.I=$n;exports.L=tn;exports.M=mn;exports.O=gn;exports.P=ut;exports.Q=ct;exports.R=en;exports.S=it;exports.T=Jt;exports.U=xt;exports.V=Pe;exports.W=rt;exports.X=Re;exports.Y=qt;exports.Z=Zt;exports._=Gt;exports.a=En;exports.a0=_t;exports.a1=dt;exports.a2=ra;exports.a3=ha;exports.b=_n;exports.c=an;exports.d=Ct;exports.f=Kt;exports.g=Nn;exports.i=kn;exports.j=Yn;exports.k=yn;exports.l=Qn;exports.n=nn;exports.o=jt;exports.q=fn;exports.r=xn;exports.s=rn;exports.t=Cn;exports.u=sn;exports.v=Vn;exports.w=bn;exports.x=on;exports.y=wn;exports.z=pn;
|