@nice2dev/ui 1.4.4 → 1.4.6
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/CHANGELOG.md +59 -0
- package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
- package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
- package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
- package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
- package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
- package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
- package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
- package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +587 -0
- package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
- package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
- package/dist/data/NiceTreeGrid.mjs +519 -458
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +20 -1
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +98 -98
- package/dist/index.d.ts +197 -1
- package/dist/index.mjs +303 -293
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
- package/dist/no-code/noCodeScript.mjs +326 -0
- package/dist/no-code-B1jzfUF5.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +177 -0
- package/dist/no-code.mjs +26 -16
- package/dist/style.css +2 -2
- package/package.json +4 -4
- package/dist/NiceForm-O3sv-DNX.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
- package/dist/NiceSavedQueryPanel-BPGpKWN2.cjs +0 -587
- package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
- package/dist/no-code-B3BHeyG-.cjs +0 -331
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),r=require("@nice2dev/ui-core"),n=require("react"),at=require("react-dom"),et=require("./NiceSelect-BNPXs6FQ.cjs"),ht=require("./pickerCommons-CwcCc8Qi.cjs"),tt=require("./devops-cgRBnZVX.cjs"),Ke=require("./NiceForm-O3sv-DNX.cjs"),ot=require("./no-code-B3BHeyG-.cjs"),sn=require("@nice2dev/i18n"),rn=require("./NiceHtmlEditor-C1OVtLQ6.cjs"),Ie=require("./NiceButton-DzCqkG5a.cjs"),Ot=require("./NiceColorPicker-BLwYNSXJ.cjs"),$t=require("./NiceCodeEditor-DhdjnDLV.cjs"),wt=require("./injectStyleOnce-DeWaxcdf.cjs"),Ln=({min:t=0,max:i=100,step:o=1,startValue:a=t,endValue:s=i,onChange:g,showLabels:x=!0,formatLabel:$,valuePlacement:P="none",label:M,error:W,helperText:J,required:B,disabled:I,readOnly:X,loading:se,size:oe="md",id:ce,className:Z,style:F,accessMode:k,showKeyboardHints:l,labelPlacement:T,errorPlacement:Y,labelWidth:A,controlWidth:_})=>{const b=r.useNiceAccessMode(k,ce),C=b==="hidden";(b==="disabled"||b==="readOnly")&&(I=!0);const{t:f}=r.useNiceTranslation(),S=r.useControlId(ce),K=n.useRef(null),w=n.useMemo(()=>[r.COMMON_SHORTCUTS.increment,r.COMMON_SHORTCUTS.decrement,r.COMMON_SHORTCUTS.first,r.COMMON_SHORTCUTS.last,{key:"Tab",description:f("shortcuts.switchThumb","Switch thumb")}],[f]),d=p=>(p-t)/(i-t)*100,D=p=>$?$(p):String(p),j=n.useCallback(p=>{const E=Math.round(p/o)*o;return Math.max(t,Math.min(i,E))},[t,i,o]),h=n.useCallback((p,E)=>{p.preventDefault();const N=K.current;if(!N||I)return;const m=z=>{const ie=N.getBoundingClientRect(),v=Math.max(0,Math.min(1,(z.clientX-ie.left)/ie.width)),ee=j(t+v*(i-t));E==="start"?g?.(Math.min(ee,s),s):g?.(a,Math.max(ee,a))},R=()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",R)};document.addEventListener("pointermove",m),document.addEventListener("pointerup",R)},[t,i,j,a,s,g,I]),c=(p,E)=>{if(I||X)return;const N=E==="start"?a:s,m=E==="start"?t:a,R=E==="start"?s:i,z=Math.max(o,(i-t)/10),ie=p.key==="ArrowRight"||p.key==="ArrowUp"?N+o:p.key==="ArrowLeft"||p.key==="ArrowDown"?N-o:p.key==="PageUp"?N+z:p.key==="PageDown"?N-z:p.key==="Home"?m:p.key==="End"?R:null;if(ie===null)return;p.preventDefault();const v=Math.max(m,Math.min(R,j(ie)));E==="start"?g?.(v,s):g?.(a,v)};return C?null:e.jsxs("div",{className:`nice-field nice-field--${oe} nice-field--rangeslider ${T==="left"?"nice-field--label-left":""} ${Y==="right"?"nice-field--error-right":""} ${W?"nice-field--error":""} ${se?"nice-field--loading":""} ${Z||""}`,style:{...F,...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},..._!=null&&{"--nice-field-control-width":typeof _=="number"?`${_}px`:_}},"aria-busy":se||void 0,children:[(M||P==="right"&&T!=="left")&&(T!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[M?e.jsx("label",{className:"nice-field__label",htmlFor:S,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:w,size:"sm"})]})}):e.jsx("span",{}),P==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[D(a)," – ",D(s)]})]}):M&&e.jsx("label",{className:"nice-field__label",htmlFor:S,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:w,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${x?"nice-range-slider--with-labels":""} ${M?"nice-range-slider--has-field-label":""}`,ref:K,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${d(a)}%`,width:`${d(s)-d(a)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(a)}%`},onPointerDown:p=>X?void 0:h(p,"start"),onKeyDown:p=>c(p,"start"),role:"slider","aria-label":f("rangeSlider.min","Minimum"),"aria-valuemin":t,"aria-valuemax":s,"aria-valuenow":a,"aria-valuetext":D(a),"aria-disabled":I||void 0,"aria-readonly":X||void 0,tabIndex:I?-1:0,id:S}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(s)}%`},onPointerDown:p=>X?void 0:h(p,"end"),onKeyDown:p=>c(p,"end"),role:"slider","aria-label":f("rangeSlider.max","Maximum"),"aria-valuemin":a,"aria-valuemax":i,"aria-valuenow":s,"aria-valuetext":D(s),"aria-disabled":I||void 0,"aria-readonly":X||void 0,tabIndex:I?-1:0})]}),x&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${d(a)}%`},children:D(a)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${d(s)}%`},children:D(s)})]}),P==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[D(a)," – ",D(s)]})]}),P==="right"&&T==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[D(a)," – ",D(s)]}),se&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),Y==="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),Y==="right"&&!W&&J&&e.jsx("div",{className:"nice-field__helper",children:J})]}),Y!=="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),Y!=="right"&&!W&&J&&e.jsx("div",{className:"nice-field__helper",children:J})]})},Pn={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},ft=6,mt=135,cn=405,lt=cn-mt;function It(t,i,o,a){const s=(a-90)*(Math.PI/180);return{x:t+o*Math.cos(s),y:i+o*Math.sin(s)}}function Bt(t,i,o,a,s){const g=It(t,i,o,a),x=It(t,i,o,s),$=s-a>180?1:0;return`M ${g.x} ${g.y} A ${o} ${o} 0 ${$} 1 ${x.x} ${x.y}`}const On=Object.assign(n.forwardRef(({value:t=0,onChange:i,min:o=0,max:a=100,step:s=1,showValue:g=!0,valueTemplate:x="{value}",label:$,helperText:P,error:M,required:W,disabled:J,readOnly:B,size:I="md",name:X,id:se,className:oe,style:ce,labelPlacement:Z="top",errorPlacement:F,labelWidth:k,controlWidth:l,loading:T,isLabelCentered:Y=!0,...A},_)=>{const b=r.useControlId(se),C=n.useRef(!1),f=n.useRef(null),S=typeof I=="number"?I:Pn[I],K=S/2,w=S/2,d=(S-ft*2)/2,D=a>o?(t-o)/(a-o):0,j=mt+D*lt,h=n.useCallback(m=>{let R=m-mt;R<0&&(R+=360),R>lt&&(R=R-lt<360-R?lt:0);const z=Math.max(0,Math.min(1,R/lt)),ie=o+z*(a-o),v=Math.round(ie/s)*s;return Math.max(o,Math.min(a,v))},[o,a,s]),c=n.useCallback(m=>{if(J||B)return;const R=f.current;if(!R)return;const z=R.getBoundingClientRect(),ie=m.clientX-z.left-z.width/2,v=m.clientY-z.top-z.height/2;let ee=Math.atan2(ie,-v)*(180/Math.PI);ee<0&&(ee+=360);const U=h(ee);i?.(U)},[h,J,B,i]);n.useEffect(()=>{const m=z=>{C.current&&c(z)},R=()=>{C.current=!1};return window.addEventListener("pointermove",m),window.addEventListener("pointerup",R),()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",R)}},[c]);const p=n.useCallback(m=>{if(J||B)return;let R=t;const z=Math.max(s,(a-o)/10);m.key==="ArrowUp"||m.key==="ArrowRight"?(m.preventDefault(),R=Math.min(a,t+s)):m.key==="ArrowDown"||m.key==="ArrowLeft"?(m.preventDefault(),R=Math.max(o,t-s)):m.key==="PageUp"||m.key==="PageDown"?(m.preventDefault(),R=Math.max(o,Math.min(a,t+(m.key==="PageUp"?z:-z)))):(m.key==="Home"||m.key==="End")&&(m.preventDefault(),R=m.key==="Home"?o:a),R!==t&&i?.(R)},[t,i,o,a,s,J,B]),E=(x||"{value}").replace("{value}",String(t)),N=It(K,w,d,j);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${F||"bottom"} nice-field--${typeof I=="string"?I:"md"} ${T?"nice-field--loading":""} ${oe||""}`,style:{...ce,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...l!=null&&{"--nice-field-control-width":typeof l=="number"?`${l}px`:l}},"aria-busy":T||void 0,...A,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${Z} ${Y?"nice-knob-field--label-centered":""}`,children:[$&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${W?"nice-field__label--required":""}`,children:$}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:m=>{f.current=m,typeof _=="function"?_(m):_&&(_.current=m)},className:`nice-knob nice-knob--${I} ${J?"nice-knob--disabled":""} ${M?"nice-knob--error":""}`,role:"slider",id:b,tabIndex:J?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":a,"aria-disabled":J,"aria-invalid":!!M,onPointerDown:m=>{J||B||(C.current=!0,c(m))},onKeyDown:p,children:[e.jsxs("svg",{width:S,height:S,viewBox:`0 0 ${S} ${S}`,children:[e.jsx("path",{d:Bt(K,w,d,mt,cn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:ft,strokeLinecap:"round"}),D>0&&e.jsx("path",{d:Bt(K,w,d,mt,j),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:ft,strokeLinecap:"round"}),e.jsx("circle",{cx:N.x,cy:N.y,r:ft,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:E}),X&&e.jsx("input",{type:"hidden",name:X,value:t}),T&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),!M&&P&&e.jsx("div",{className:"nice-field__helper",children:P})]})}),{displayName:"NiceKnob"}),Bn=({options:t,value:i,defaultValue:o,onChange:a,searchable:s=!0,clearable:g,loading:x,placeholder:$,label:P,error:M,helperText:W,required:J,disabled:B,readOnly:I,size:X="md",id:se,className:oe,style:ce,data:Z,columns:F,valueField:k="id",displayField:l,dropdownWidth:T,menuGap:Y,labelPlacement:A,errorPlacement:_,labelWidth:b,controlWidth:C})=>{const f=B||I||x,S=r.useControlId(se),{t:K}=r.useNiceTranslation(),[w,d]=r.useControllableState({value:i,defaultValue:o,fallbackValue:"",onChange:a,componentName:"NiceLookup"}),[D,j]=n.useState(!1),[h,c]=n.useState(""),p=n.useRef(null),E=n.useRef(null),{popupRef:N,coords:m,ready:R,themeClass:z,portalTarget:ie}=et.useAnchoredPopup(D,E,()=>j(!1)),v=!!(Z&&F&&F.length>0),ee=l??(F&&F[0]?.key),U=n.useMemo(()=>!v||!Z?[]:Z.map(re=>({value:String(re[k]??""),label:ee?String(re[ee]??""):""})),[v,Z,k,ee]),me=n.useMemo(()=>v?U:t??[],[v,U,t]),pe=me.find(re=>String(re.value)===w),ye=n.useMemo(()=>{if(!v||!Z)return[];if(!h)return Z;const re=h.toLowerCase();return Z.filter(fe=>F.some(H=>String(fe[H.key]??"").toLowerCase().includes(re)))},[v,Z,F,h]),ue=n.useMemo(()=>{if(v||!h)return me;const re=h.toLowerCase();return me.filter(fe=>fe.label.toLowerCase().includes(re))},[me,h,v]),he=v?ye:ue,{activeIndex:de,setActiveIndex:ge,handleKeyDown:ae}=ht.useListKeyboardNav(he,{open:D,onSelect:re=>{const fe=String(v?re[k]??"":re.value);d(fe),j(!1),c("")},onClose:()=>j(!1),onOpen:()=>!f&&j(!0),intentRef:N}),_e=`${n.useId()}-listbox`,te=re=>`${_e}-opt-${re}`,we=D&&he.length>0?te(de):void 0;return n.useLayoutEffect(()=>{we&&document.getElementById(we)?.scrollIntoView?.({block:"nearest"})},[we]),e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${X} ${M?"nice-field--error":""} ${A==="left"?"nice-field--label-left":""} ${_==="right"&&(M||W)?"nice-field--error-right":""} ${x?"nice-field--loading":""} ${B?"nice-field--disabled":""} ${oe||""}`,style:{...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C},...b!=null&&{"--nice-field-label-width":typeof b=="number"?`${b}px`:b},...Y!=null&&{"--nice-dropdown-gap":`${Y}px`},...ce},"aria-busy":x||void 0,ref:p,children:[P&&e.jsxs("label",{className:"nice-field__label",htmlFor:S,children:[P,J&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-field__input-wrap",ref:E,children:[e.jsxs("button",{type:"button",id:S,className:`nice-select__trigger ${B?"nice-select__trigger--disabled":""}`,onClick:()=>!f&&j(!D),onKeyDown:ae,disabled:B,"aria-readonly":I||void 0,role:"combobox","aria-haspopup":"listbox","aria-expanded":D,"aria-controls":D?_e:void 0,"aria-activedescendant":s?void 0:we,children:[e.jsx("span",{children:pe?.label||$||K("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[g&&w&&!B&&!I&&e.jsx("span",{onKeyDown:r.clickOnActivationKey,className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":K("controls.clear","Clear"),onClick:re=>{re.stopPropagation(),d("")},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${I?" nice-select__arrow--hidden":""}`,children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),D&&m&&ie&&at.createPortal(e.jsxs("div",{ref:N,className:`nice-dropdown nice-lookup__dropdown${z?` ${z}`:""}`,"data-theme":z==="nice-dark"?"dark":z==="nice-light"?"light":void 0,style:{position:"fixed",top:m.top,left:m.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:m.width,width:T!=null?typeof T=="number"?`${T}px`:T:v?"max-content":m.width,opacity:R?1:0,pointerEvents:R?void 0:"none"},children:[s&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:h,onChange:re=>{c(re.target.value),ge(0)},onKeyDown:ae,placeholder:K("controls.search","Search..."),"aria-label":K("controls.search","Search..."),"aria-controls":_e,"aria-activedescendant":we,"aria-autocomplete":"list",autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),v?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",id:_e,style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:F.map(re=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:re.width!=null?typeof re.width=="number"?`${re.width}px`:re.width:void 0},children:re.header},re.key))})}),e.jsx("tbody",{children:ye.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:K("controls.noResults","No results")})}):ye.map((re,fe)=>{const H=String(re[k]??""),q=H===w,O=fe===de;return e.jsx("tr",{id:te(fe),role:"option","aria-selected":q,onClick:()=>{d(H),j(!1),c("")},style:{cursor:"pointer",background:q||O?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>ge(fe),children:F.map(y=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(re[y.key]??"")},y.key))},H)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",id:_e,style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:ue.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:K("controls.noResults","No results")}):ue.map((re,fe)=>e.jsx("li",{id:te(fe),role:"option",className:`nice-dropdown__option ${String(re.value)===w?"nice-dropdown__option--selected":""} ${fe===de?"nice-dropdown__option--active":""}`,onClick:()=>{d(String(re.value)),j(!1),c("")},onMouseEnter:()=>ge(fe),"aria-selected":String(re.value)===w,children:re.label},String(re.value)))})]}),ie)]}),x&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),_==="right"&&M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),_==="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]}),_!=="right"&&M&&e.jsx("div",{className:"nice-field__error",children:M}),_!=="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]})},Hn=[];function Ht(t){const i=[],o=a=>{for(const s of a)i.push(s),s.children&&o(s.children)};return o(t),i}function ln(t,i){const o=i.toLowerCase();return t.reduce((a,s)=>{const g=s.children?ln(s.children,i):[];return(s.label.toLowerCase().includes(o)||g.length>0)&&a.push({...s,children:g.length>0?g:s.children}),a},[])}const dn=({node:t,level:i,selectedKeys:o,expandedKeys:a,onToggleExpand:s,onSelect:g,selectableLeafsOnly:x,maxDepth:$})=>{const{t:P}=r.useNiceTranslation(),M=typeof $=="number"?Math.min(10,Math.max(1,$)):1/0,J=!(i+1>=M)&&t.children&&t.children.length>0,B=a.has(t.key),I=o.has(t.key),X=!J,se=!t.disabled&&(!x||X),oe=Math.min(i+1,10),ce={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${oe}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${oe}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${oe}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${oe}-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 ${I?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ce,"data-nice-depth":oe,onClick:()=>{t.disabled||(J?s(t.key):se&&g(t.key))},role:"treeitem","aria-level":i+1,"aria-selected":I,"aria-expanded":J?B:void 0,"aria-disabled":t.disabled,"data-key":String(t.key),children:[J?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",tabIndex:-1,onClick:Z=>{Z.stopPropagation(),s(t.key)},"aria-label":P("controls.toggle","Toggle"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:12,style:{transform:B?"rotate(90deg)":"none",transition:"transform 0.15s"}})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),J&&B&&t.children.map(Z=>e.jsx(dn,{node:Z,level:i+1,selectedKeys:o,expandedKeys:a,onToggleExpand:s,onSelect:g,selectableLeafsOnly:x,maxDepth:$},Z.key))]})},Fn=Object.assign(n.forwardRef(({nodes:t=Hn,value:i,onChange:o,multiple:a=!1,searchable:s=!1,placeholder:g,selectableLeafsOnly:x=!1,clearable:$=!1,maxDepth:P,label:M,helperText:W,error:J,required:B,disabled:I,readOnly:X,size:se="md",name:oe,id:ce,className:Z,style:F,controlWidth:k,menuGap:l,labelPlacement:T,errorPlacement:Y,labelWidth:A,..._},b)=>{const{t:C}=r.useNiceTranslation(),f=r.useControlId(ce),[S,K]=n.useState(!1),[w,d]=n.useState(""),[D,j]=n.useState(new Set),h=n.useRef(null),{popupRef:c,coords:p,ready:E,themeClass:N,portalTarget:m}=et.useAnchoredPopup(S,h,()=>K(!1)),R=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),z=n.useMemo(()=>w?ln(t,w):t,[t,w]),ie=n.useMemo(()=>{const he=Ht(t);return Array.from(R).map(de=>he.find(ge=>ge.key===de)?.label).filter(Boolean)},[R,t]),v=n.useCallback(he=>{j(de=>{const ge=new Set(de);return ge.has(he)?ge.delete(he):ge.add(he),ge})},[]),ee=n.useCallback(he=>{if(a){const de=new Set(R);de.has(he)?de.delete(he):de.add(he),o?.(Array.from(de))}else o?.(he),K(!1)},[a,R,o]),U=n.useCallback(he=>{he.stopPropagation(),o?.(a?[]:"")},[o,a]),me=n.useRef(null),pe=`${f}-tree`;r.useTreeFocus(me,{onToggle:(he,de)=>{const ge=Ht(z).find(ae=>String(ae.key)===he.dataset.key);ge&&D.has(ge.key)!==de&&v(ge.key)}});const ye=n.useCallback(()=>(me.current?.querySelector('[role="treeitem"][tabindex="0"]')??me.current?.querySelector('[role="treeitem"]'))?.focus(),[]),ue=!!p;return n.useEffect(()=>{S&&ue&&!s&&ye()},[S,ue,s,ye]),e.jsxs("div",{className:`nice-field nice-field--${se}${T?` nice-field--label-${T}`:""}${Y==="right"?" nice-field--error-right":""} ${Z||""}`,style:{width:"fit-content",maxWidth:"100%",...l!=null&&{"--nice-dropdown-gap":`${l}px`},...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},...F},..._,children:[M&&e.jsx("label",{htmlFor:f,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:M}),e.jsxs("div",{ref:h,className:"nice-tree-select",style:{position:"relative",width:k!=null&&k!==""?typeof k=="number"?`${k}px`:k:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:b,id:f,className:`nice-input nice-input--${se} ${J?"nice-input--error":""} ${I?"nice-input--disabled":""} ${X?"nice-input--readonly":""}`,role:"combobox","aria-expanded":S,"aria-haspopup":"tree","aria-controls":S?pe:void 0,"aria-invalid":!!J,tabIndex:I?-1:0,onClick:()=>!I&&!X&&K(!S),onKeyDown:he=>{(he.key==="Enter"||he.key===" "||he.key==="ArrowDown"||he.key==="ArrowUp")&&!I&&!X&&(he.preventDefault(),S?ye():K(!0))},children:[e.jsx("span",{className:"nice-tree-select__display",children:ie.length>0?ie.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??C("controls.select","Select...")})}),$&&R.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:U,"aria-label":C("controls.clear","Clear"),children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:S?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(r.NiceIcon,{name:"chevron-down",size:14})})]}),S&&p&&m&&at.createPortal(e.jsxs("div",{ref:c,className:`nice-tree-select__dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",left:p.left,top:p.top,width:p.width,minWidth:p.width,zIndex:1e3,opacity:E?1:0,pointerEvents:E?void 0:"none"},children:[s&&e.jsx("div",{className:"nice-select__search",onClick:he=>he.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:C("controls.search","Search..."),"aria-label":C("controls.search","Search..."),"aria-controls":pe,value:w,onChange:he=>d(he.target.value),onKeyDown:he=>{he.key==="ArrowDown"&&(he.preventDefault(),ye())},autoFocus:!0})}),e.jsx("div",{ref:me,id:pe,className:"nice-tree-select__list",role:"tree","aria-label":M||g||C("controls.select","Select..."),"aria-multiselectable":a||void 0,children:z.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:C("controls.noResults","No results")}):z.map(he=>e.jsx(dn,{node:he,level:0,selectedKeys:R,expandedKeys:D,onToggleExpand:v,onSelect:ee,selectableLeafsOnly:x,maxDepth:P},he.key))})]}),m)]}),oe&&e.jsx("input",{type:"hidden",name:oe,value:Array.isArray(i)?i.join(","):i??""}),J&&e.jsx("div",{id:`${f}-error`,className:"nice-field__error",role:"alert",children:J}),!J&&W&&e.jsx("div",{id:`${f}-helper`,className:"nice-field__helper",children:W})]})}),{displayName:"NiceTreeSelect"}),Kn=({displayValue:t,placeholder:i,clearable:o,children:a,onClear:s,open:g,onOpenChange:x,dropdownWidth:$,searchable:P=!0,onSearch:M,searchPlaceholder:W,label:J,error:B,helperText:I,required:X,disabled:se,size:oe="md",id:ce,className:Z,style:F,accessMode:k,showKeyboardHints:l,displayStyle:T})=>{r.useComponentDisplayStyle("input",T),r.useComponentDisplayClass("input",T);const Y=r.useNiceAccessMode(k,ce),A=Y==="hidden";(Y==="disabled"||Y==="readOnly")&&(se=!0);const _=r.useControlId(ce),{t:b}=r.useNiceTranslation(),[C,f]=n.useState(!1),[S,K]=n.useState(""),w=n.useRef(null),d=n.useRef(null),D=g??C,j=n.useMemo(()=>[{key:"Enter",description:b("shortcuts.openDropdown","Open dropdown")},r.COMMON_SHORTCUTS.cancel],[b]),h=R=>{x?x(R):f(R)},{popupRef:c,coords:p,ready:E,themeClass:N,portalTarget:m}=et.useAnchoredPopup(D,d,()=>h(!1));return A?null:e.jsxs("div",{className:`nice-field nice-field--${oe} ${B?"nice-field--error":""} ${Z||""}`,style:F,ref:w,children:[J&&e.jsxs("label",{className:"nice-field__label",htmlFor:_,children:[J,X&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:j,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:d,children:[e.jsxs("button",{type:"button",id:_,className:"nice-select__trigger",onClick:()=>!se&&h(!D),disabled:se,children:[e.jsx("span",{children:t||i||b("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[o&&t&&!se&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":b("controls.clear","Clear"),onClick:R=>{R.stopPropagation(),s?.()},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),R.stopPropagation(),s?.())},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),D&&p&&m&&at.createPortal(e.jsxs("div",{ref:c,className:`nice-dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",left:p.left,top:p.top,width:$??p.width,minWidth:$??p.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:E?1:0,pointerEvents:E?void 0:"none"},children:[P&&M&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:S,onChange:R=>{K(R.target.value),M(R.target.value)},placeholder:W??b("controls.search","Search..."),autoFocus:!0})}),a]}),m)]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),I&&!B&&e.jsx("div",{className:"nice-field__hint",children:I})]})},Un=[],Yn=[];function Qe(t,i){return String(t[i])}const qn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},Xn=Object.assign(n.forwardRef(({source:t=Un,target:i=Yn,onChange:o,keyField:a="id",labelField:s="label",renderItem:g,filterable:x=!1,searchable:$,groupBy:P,sortable:M=!1,bulkActions:W=!0,maxRight:J,sourceHeader:B,targetHeader:I,disabled:X=!1,size:se="md",className:oe,style:ce,id:Z,...F},k)=>{const{t:l}=r.useNiceTranslation(),T=qn[se]??14,[Y,A]=n.useState(new Set),[_,b]=n.useState(new Set),[C,f]=n.useState(""),[S,K]=n.useState(""),[w,d]=n.useState(null),D=n.useRef(null),j=n.useRef(null),h={orientation:"vertical",typeahead:!0,pageSize:10};r.useRovingFocus(D,h),r.useRovingFocus(j,h);const c=n.useCallback((v,ee,U)=>{ee(me=>{const pe=new Set(me);return pe.has(U)?pe.delete(U):pe.add(U),pe})},[]),p=n.useCallback(()=>{const v=t.filter(pe=>Y.has(Qe(pe,a))),ee=t.filter(pe=>!Y.has(Qe(pe,a))),U=typeof J=="number"?v.slice(0,Math.max(0,J-i.length)):v,me=v.slice(U.length);o([...ee,...me],[...i,...U]),A(new Set)},[t,i,Y,a,o,J]),E=n.useCallback(()=>{const v=i.filter(U=>_.has(Qe(U,a))),ee=i.filter(U=>!_.has(Qe(U,a)));o([...t,...v],ee),b(new Set)},[t,i,_,a,o]),N=n.useCallback(()=>{if(typeof J=="number"){const v=Math.max(0,J-i.length),ee=t.slice(0,v),U=t.slice(v);o(U,[...i,...ee])}else o([],[...i,...t]);A(new Set)},[t,i,o,J]),m=n.useCallback(()=>{o([...t,...i],[]),b(new Set)},[t,i,o]),R=(v,ee)=>{if(!ee)return v;const U=ee.toLowerCase();return v.filter(me=>String(me[s]).toLowerCase().includes(U))},z=W===!1?{moveAll:!1,removeAll:!1}:W===!0||W===void 0?{moveAll:!0,removeAll:!0}:{moveAll:W.moveAll??!0,removeAll:W.removeAll??!0},ie=(v,ee,U,me,pe,ye,ue,he)=>{let de=R(v,me);M||(de=[...de].sort((re,fe)=>String(re[s]).localeCompare(String(fe[s]),void 0,{numeric:!0,sensitivity:"base"})));const ge=$===!0||x&&$===void 0?"both":$??!1,ae=ge==="both"||ge==="left"&&ue==="left"||ge==="right"&&ue==="right",ve=(()=>{if(!P)return[{label:"",items:de}];const re=new Map;for(const fe of de){const H=String(P(fe));let q=re.get(H);q||(q=[],re.set(H,q)),q.push(fe)}return[...re.entries()].map(([fe,H])=>({label:fe,items:H}))})(),_e=(re,fe)=>{re.dataTransfer.setData("text/plain",fe),re.dataTransfer.effectAllowed="move"},te=(re,fe)=>{if(re.preventDefault(),!M)return;const H=re.currentTarget.getBoundingClientRect(),q=re.clientY<H.top+H.height/2;d(O=>O&&O.side===ue&&O.key===fe&&O.before===q?O:{side:ue,key:fe,before:q})},we=(re,fe)=>{re.preventDefault();const H=w?.before??!1;d(null);const q=re.dataTransfer.getData("text/plain");if(!q||!M)return;const y=[...ue==="right"?i:t],G=y.findIndex(xe=>Qe(xe,a)===q),ne=y.findIndex(xe=>Qe(xe,a)===fe);if(G===-1||ne===-1||q===fe)return;let le=H?ne:ne+1;const[be]=y.splice(G,1);G<le&&(le-=1),y.splice(le,0,be),o(ue==="right"?t:y,ue==="right"?y:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[ye&&e.jsx("div",{className:"nice-picklist__header",children:ye}),ae&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:l("controls.search","Search..."),value:me,onChange:re=>pe(re.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true","aria-label":typeof ye=="string"?ye:void 0,ref:he,children:[ve.map(re=>e.jsxs(n.Fragment,{children:[re.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:re.label}),re.items.map(fe=>{const H=Qe(fe,a),q=ee.has(H),y=w&&w.side===ue&&w.key===H?w.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${q?"nice-picklist__item--selected":""} ${y}`,role:"option","aria-selected":q,draggable:M,onDragStart:M?G=>_e(G,H):void 0,onDragOver:M?G=>te(G,H):void 0,onDrop:M?G=>we(G,H):void 0,onDragEnd:M?()=>d(null):void 0,onClick:()=>!X&&c(ee,U,H),onKeyDown:G=>{(G.key===" "||G.key==="Enter")&&(G.preventDefault(),X||c(ee,U,H))},children:[M&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsx(r.NiceIcon,{name:"grip",size:T})}),g?g(fe,ue):String(fe[s])]},H)})]},re.label||"__none__")),de.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:l("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:k,id:Z,className:`nice-picklist nice-picklist--${se} ${X?"nice-picklist--disabled":""} ${oe||""}`,style:ce,...F,children:[ie(t,Y,A,C,f,B??l("picklist.source","Available"),"left",D),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:X||Y.size===0,onClick:p,"aria-label":l("picklist.moveRight","Move right"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:T})}),z.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:X||t.length===0,onClick:N,"aria-label":l("picklist.moveAllRight","Move all right"),children:e.jsx(r.NiceIcon,{name:"chevrons-right",size:T})}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:X||_.size===0,onClick:E,"aria-label":l("picklist.moveLeft","Move left"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:T})}),z.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:X||i.length===0,onClick:m,"aria-label":l("picklist.moveAllLeft","Move all left"),children:e.jsx(r.NiceIcon,{name:"chevrons-left",size:T})})]}),ie(i,_,b,S,K,I??l("picklist.target","Selected"),"right",j)]})}),{displayName:"NicePickList"});function Rt(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function Vn(t){const i=new Date,o=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,a=Rt(t);return a==="datetime"?`${o}T00:00`:a==="month"?o.slice(0,7):o}function Ft(t,i){if(!t)return t;const o=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(o.getTime()))return t;o.setDate(o.getDate()+i);const a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`;return t.length<=10?a.slice(0,t.length):a+t.slice(10)}function yt(...t){return t.filter(Boolean).sort().pop()}function Kt(t,i,o){if(!t)return"";const a=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(a.getTime()))return t;const s=Rt(o);return s==="month"?a.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):s==="datetime"?a.toLocaleString(i,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):a.toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"})}function Ut(t){let i=0;for(const o of t)i+=/[\p{L}\p{N}]/u.test(o)?1:.5;return i}function Yt(t){const i=/^(\d{4})-(\d{2})(?:-(\d{2}))?(?:T(\d{2}):(\d{2}))?$/.exec(t);if(!i)return!1;const[,o,a,s="01",g="00",x="00"]=i,$=new Date(Number(o),Number(a)-1,Number(s));return $.getMonth()===Number(a)-1&&$.getDate()===Number(s)&&Number(g)<24&&Number(x)<60}const Gn=({startDate:t,endDate:i,defaultStartDate:o,defaultEndDate:a,onStartChange:s,onEndChange:g,min:x,max:$,clearable:P,startPlaceholder:M,endPlaceholder:W,startLabel:J,endLabel:B,layout:I="horizontal",separator:X="–",gap:se=12,fullWidth:oe=!1,dateFormatPreset:ce,locale:Z,timeSelectorType:F,endCondition:k="greater-or-equal",startCondition:l="today-or-greater",singleField:T=!1,label:Y,error:A,helperText:_,required:b,disabled:C,size:f="md",id:S,className:K,style:w,accessMode:d,showKeyboardHints:D,labelPlacement:j,errorPlacement:h,labelWidth:c,controlWidth:p,loading:E,readOnly:N})=>{const m=r.useNiceAccessMode(d,S),R=r.useControlId(S),{t:z}=r.useNiceTranslation(),ie=m==="disabled"||m==="readOnly"||!!C,[v,ee]=r.useControllableState({value:t,defaultValue:o,fallbackValue:"",onChange:s,componentName:"NiceDateRangeBox"}),[U,me]=r.useControllableState({value:i,defaultValue:a,fallbackValue:"",onChange:g,componentName:"NiceDateRangeBox"}),pe=n.useMemo(()=>[{key:"Tab",description:z("shortcuts.switchField","Switch between start/end")},r.COMMON_SHORTCUTS.cancel],[z]),ye=n.useRef(null),ue=n.useRef(null),[he,de]=n.useState(!1),[ge,ae]=n.useState(null),[ve,_e]=n.useState(""),te=n.useContext(r.NiceThemeContext),we=te?.portalTarget??(typeof document<"u"?document.body:null),re=Z||Ke.getDefaultLocale(),fe=n.useMemo(()=>Ke.rangeMaskSpec(ce,re),[ce,re]),[H,q]=n.useState(null);n.useLayoutEffect(()=>{if(!he)return;const L=ye.current?.getBoundingClientRect();L&&(ae({left:L.left,top:L.bottom+6}),_e(te?.portalTarget?"":tt.scopeThemeClass(ye.current)))},[he,te?.portalTarget]),n.useEffect(()=>{if(!he)return;const L=Ce=>{const Pe=Ce.target;ye.current?.contains(Pe)||ue.current?.contains(Pe)||de(!1)},ke=()=>{const Ce=ye.current?.getBoundingClientRect();Ce&&ae({left:Ce.left,top:Ce.bottom+6})};return document.addEventListener("mousedown",L),window.addEventListener("scroll",ke,!0),window.addEventListener("resize",ke),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("scroll",ke,!0),window.removeEventListener("resize",ke)}},[he]),r.useOverlayFocus(ue,{open:he,modal:!1,initialFocus:'.nice-calendar__grid [tabindex="0"]',onClose:()=>de(!1)});const O=Vn(ce),y=l==="today-or-greater"?yt(x,O):l==="greater-than-today"?yt(x,Ft(O,1)):x,G=k==="greater-or-equal"?yt(x,v):k==="greater"?yt(x,v?Ft(v,1):void 0):x,ne=n.useMemo(()=>{if(A)return A;if(v&&U){if(k==="greater-or-equal"&&U<v)return z("daterange.endBeforeStart","End date must be on or after the start date");if(k==="greater"&&U<=v)return z("daterange.endAfterStart","End date must be after the start date")}if(v){if(l==="today-or-greater"&&v<O)return z("daterange.startInPast","Start date cannot be in the past");if(l==="greater-than-today"&&v<=O)return z("daterange.startAfterToday","Start date must be after today")}},[A,v,U,l,k,O,z]);if(m==="hidden")return null;const le=L=>{ee(L),L&&U&&L>U&&me(L)},be=I==="horizontal",xe=Rt(ce),Se=re,Te=typeof X=="string"&&X!==""?X:"–",Me=xe!=="week"&&ce!=="time",ze=Ke.dateMaskDigits.slots(fe),qe=L=>L?Me?Ke.dateMaskDigits.render(fe,Ke.dateMaskDigits.fromIso(fe,L)):Kt(L,Se,ce):"",Xe=qe(v),Ve=qe(U),Ge=Xe||Ve?`${Xe||"…"} ${Te} ${Ve||"…"}`:"",Ee=L=>{const ke=Ke.dateMaskDigits.render(fe,L.slice(0,ze));return L.length<ze?ke:`${ke} ${Te} ${Ke.dateMaskDigits.render(fe,L.slice(ze))}`},We=`${fe.placeholder} ${Te} ${fe.placeholder}`,$e=(()=>{const L=Me?fe.placeholder:Kt("2026-12-30T22:58",Se,ce),ke=`${L} ${Te} ${L}`;return`${(Math.max(Ut(ke),Ut(Ge))+1.5).toFixed(1)}ch`})(),Je=(L,ke)=>xe==="datetime"?ke&&ke.length>10?`${L}${ke.slice(10)}`:`${L}T00:00`:xe==="month"?L.slice(0,7):L,Le=({start:L,end:ke})=>{q(null),ee(L?Je(L,v):""),me(ke?Je(ke,U):""),L&&ke&&de(!1)},Ae=()=>{q(null),ee(""),me("")},Oe=L=>{const ke=H!==null?Ee(H):Ge;let Ce=L.replace(/\D/g,"").slice(0,ze*2);if(L.length<ke.length&&Ce===ke.replace(/\D/g,"")&&(Ce=Ce.slice(0,-1)),Ce.length===0){Ae();return}q(Ce);const Pe=Ce.length>=ze?Ke.dateMaskDigits.toIso(fe,Ce.slice(0,ze)):"";Pe&&Yt(Pe)&&Pe!==v&&ee(Pe);const He=Ce.length===ze*2?Ke.dateMaskDigits.toIso(fe,Ce.slice(ze)):"";He&&Yt(He)&&He!==U&&me(He)},st=()=>{H!==null&&(H.length<ze&&ee(""),H.length<ze*2&&me(""),q(null))},u=()=>{!ie&&!N&&de(L=>!L)},V=L=>L&&L.length>=10?L.slice(0,10):L||void 0;return e.jsxs("div",{className:`nice-field nice-field--${f} nice-daterange nice-daterange--${I} ${j==="left"?"nice-field--label-left":""} ${ne?"nice-field--error":""} ${E?"nice-field--loading":""} ${K||""}`,style:{...w,...c!=null&&{"--nice-field-label-width":typeof c=="number"?`${c}px`:c},...p!=null&&{"--nice-field-control-width":typeof p=="number"?`${p}px`:p}},"aria-busy":E||void 0,children:[Y&&e.jsxs("label",{className:"nice-field__label",htmlFor:R,children:[Y,b&&e.jsx("span",{className:"nice-field__required",children:"*"}),D&&e.jsx(r.NiceKeyboardHint,{shortcuts:pe,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[T?e.jsxs("div",{ref:ye,className:`nice-input nice-input--date nice-input--${f} nice-daterange__single ${ne?"nice-input--error":""} ${ie?"nice-input--disabled":""} ${N?"nice-input--readonly":""}`,style:{position:"relative",width:oe?"100%":"fit-content"},children:[e.jsx("input",{id:R,className:"nice-input__native",type:"text",readOnly:!Me||N,value:H!==null?Ee(H):Ge,placeholder:M||(Me?We:z("controls.startDate","Start date")),disabled:ie||E,autoComplete:"off",spellCheck:!1,inputMode:Me?"numeric":void 0,"aria-invalid":!!ne,"aria-label":Y?void 0:z("controls.startDate","Start date"),"aria-haspopup":"dialog","aria-expanded":he,onClick:Me?void 0:u,onChange:Me?L=>Oe(L.target.value):void 0,onBlur:Me?st:void 0,onKeyDown:L=>{const ke=!!L.nativeEvent.niceSource;(L.key==="Enter"||L.key===" "&&!Me||L.key==="ArrowDown"&&!ke)&&(L.preventDefault(),he||u())},style:{width:oe?"100%":$e,cursor:ie||N?void 0:Me?"text":"pointer"}}),P&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Ae,disabled:!v&&!U||ie||N,"aria-label":z("controls.clear","Clear"),tabIndex:(v||U)&&!ie&&!N?0:-1,children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:u,"aria-label":z("controls.openPicker","Open picker"),"aria-expanded":he,tabIndex:-1,disabled:ie||N,children:e.jsx(r.NiceIcon,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:be?"row":"column",alignItems:be?j==="left"?"center":"flex-end":"stretch",gap:se,flexWrap:be?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:oe?"1 1 0":void 0,minWidth:0},children:e.jsx(Ke.NiceDateTimePicker,{id:R,dateFormatPreset:ce,displayLocale:Z,timeSelectorType:F,label:J,value:v,onChange:le,min:y,max:U||$,placeholder:M,disabled:ie,readOnly:N,size:f,clearable:P,labelPlacement:j,labelWidth:c})}),be&&X!==""&&X!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:X}),e.jsx("div",{style:{flex:oe?"1 1 0":void 0,minWidth:0},children:e.jsx(Ke.NiceDateTimePicker,{dateFormatPreset:ce,displayLocale:Z,timeSelectorType:F,label:B,value:U,onChange:L=>me(L),min:G||v||x,max:$,placeholder:W,disabled:ie,readOnly:N,size:f,clearable:P,labelPlacement:j,labelWidth:c})})]}),T&&he&&ge&&we&&at.createPortal(e.jsxs("div",{ref:ue,className:`nice-datetime-popup${ve?` ${ve}`:""}`,style:{position:"fixed",left:ge.left,top:ge.top,zIndex:1e3},role:"dialog","aria-label":z("controls.openPicker","Open picker"),children:[e.jsx("div",{className:"nice-datetime-popup__body",children:e.jsx("div",{className:"nice-datetime-popup__col nice-datetime-popup__col--date",children:e.jsx(Ke.NiceCalendar,{selectionMode:"range",rangeStart:V(v),rangeEnd:V(U),onRangeChange:Le,min:V(y),max:V($),size:f})})}),P&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Ae,disabled:!v&&!U,children:z("controls.clear","Clear")})})]}),we),E&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),h==="right"&&ne&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ne}),h==="right"&&!ne&&_&&e.jsx("div",{className:"nice-field__helper",children:_})]}),h!=="right"&&ne&&e.jsx("div",{className:"nice-field__error",children:ne}),h!=="right"&&!ne&&_&&e.jsx("div",{className:"nice-field__hint",children:_})]})};function Wn(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"analogous-complementary":return[0,-i,i,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function qt(t,i={}){const o=i.size??16,a="currentColor",s="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const J=Math.max(3,Math.min(7,i.count??5)),B=o*.1,I=o-B*2,X=Math.max(1.2,o/14),se=o/2,oe=Array.from({length:J},(ce,Z)=>{const F=B+I*Z/(J-1),k=.25+.75*Z/(J-1);return e.jsx("circle",{cx:F,cy:se,r:X,fill:s,opacity:k},Z)});return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:o/2-o/6,width:o-2,height:o/3,rx:o/6,fill:"none",stroke:a,strokeOpacity:.25}),oe]})}const x=i.angles??Wn(t),$=o/2,P=o/2,M=o/2-2,W=Math.max(1.4,o/9);return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:$,cy:P,r:M,fill:"none",stroke:a,strokeOpacity:.25}),x.map((J,B)=>{const I=(J-90)*Math.PI/180,X=$+M*Math.cos(I),se=P+M*Math.sin(I);return e.jsx("circle",{cx:X,cy:se,r:W,fill:s},B)})]})}function Xt(t,i,o){return Math.max(i,Math.min(o,t))}function mn({h:t,s:i,v:o}){t=(t%360+360)%360;const a=o*i,s=a*(1-Math.abs(t/60%2-1)),g=o-a;let x=0,$=0,P=0;return t<60?(x=a,$=s):t<120?(x=s,$=a):t<180?($=a,P=s):t<240?($=s,P=a):t<300?(x=s,P=a):(x=a,P=s),{r:Math.round((x+g)*255),g:Math.round(($+g)*255),b:Math.round((P+g)*255)}}function At({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),s=Math.min(t,i,o),g=a-s;let x=0;return g!==0&&(a===t?x=(i-o)/g%6:a===i?x=(o-t)/g+2:x=(t-i)/g+4,x=(x*60+360)%360),{h:x,s:a===0?0:g/a,v:a}}function un({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),s=Math.min(t,i,o),g=(a+s)/2;if(a===s)return{h:0,s:0,l:g};const x=a-s,$=g>.5?x/(2-a-s):x/(a+s);let P=0;return a===t?P=((i-o)/x+(i<o?6:0))/6:a===i?P=((o-t)/x+2)/6:P=((t-i)/x+4)/6,{h:P*360,s:$,l:g}}function pt(t){const i=t.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,a=parseInt(o,16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function pn({r:t,g:i,b:o}){return"#"+[t,i,o].map(a=>a.toString(16).padStart(2,"0")).join("")}function Be(t){return pn(mn(t))}function Ue(t){return At(pt(t))}function hn(t,i){const o=[];for(let a=0;a<i;a++){const s=i<=1?.5:a/(i-1),g=Xt(t.s*(.3+s*.7),0,1),x=Xt(t.v*(1.2-s*.7),0,1);o.push(Be({h:t.h,s:g,v:x}))}return o}function kt(t,i){if(t==="custom"||t==="shade-chain")return[0];const o=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"analogous-complementary":return[0,-o,o,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function ut(t,i,o){return kt(i,o).map(a=>((t+a)%360+360)%360)}function Vt(t,i,o=.12){const a=Math.max(2,i),s=(a-1)/2,g=[];for(let x=0;x<a;x++){const $=(x-s)*o,P=Math.max(.05,Math.min(.98,t.v+$)),M=Math.max(.05,Math.min(1,t.s-Math.abs($)*.25));g.push(Be({h:t.h,s:M,v:P}))}return g}function Gt({r:t,g:i,b:o}){const[a,s,g]=[t,i,o].map(x=>{const $=x/255;return $<=.03928?$/12.92:Math.pow(($+.055)/1.055,2.4)});return .2126*a+.7152*s+.0722*g}function bt(t,i){const o=Gt(pt(t)),a=Gt(pt(i)),s=Math.max(o,a),g=Math.min(o,a);return(s+.05)/(g+.05)}function jt(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const gn={"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 vt(t,i){const o=gn[i];return t.map(a=>{const s=(o.sRange[0]+o.sRange[1])/2,g=(o.vRange[0]+o.vRange[1])/2;return Be({h:a,s,v:g})})}function Jn(){return Math.floor(Math.random()*360)}function fn(t,i,o){const a=Jn(),s=ut(a,t,o),g=[];for(let x=0;x<i;x++){const $=s[x%s.length],P=.55+Math.random()*.4,M=.5+Math.random()*.45;g.push(Be({h:$+(Math.random()-.5)*8,s:P,v:M}))}return g}const Zn=({hues:t,colors:i,baseHue:o,onBaseHueChange:a,mode:s,distance:g,disabled:x})=>{const{t:$}=r.useNiceTranslation(),P=240,M=P/2,W=P/2,J=110,B=55,I=l=>{if(x)return;const T=l.shiftKey?15:1,Y=l.key==="ArrowLeft"||l.key==="ArrowDown"?-T:l.key==="ArrowRight"||l.key==="ArrowUp"?T:l.key==="PageDown"?-15:l.key==="PageUp"?15:null;Y!==null?(l.preventDefault(),a(((o+Y)%360+360)%360)):(l.key==="Home"||l.key==="End")&&(l.preventDefault(),a(l.key==="Home"?0:359))},X=n.useRef(null),se=n.useCallback((l,T)=>{const Y=X.current;if(!Y)return;const A=Y.getBoundingClientRect(),_=(l-A.left)/A.width*P-M,b=(T-A.top)/A.height*P-W,C=(Math.atan2(b,_)*180/Math.PI+360)%360;a(Math.round(C))},[M,W,P,a]),oe=n.useCallback(l=>{if(x)return;l.preventDefault(),se(l.clientX,l.clientY);const T=A=>se(A.clientX,A.clientY),Y=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",Y)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",Y)},[x,se]),ce=[];for(let l=0;l<360;l+=2){const T=(l-1)*Math.PI/180,Y=(l+1)*Math.PI/180,A=Be({h:l,s:1,v:1});ce.push(e.jsx("path",{d:`M${M+B*Math.cos(T)},${W+B*Math.sin(T)} L${M+J*Math.cos(T)},${W+J*Math.sin(T)} A${J},${J} 0 0,1 ${M+J*Math.cos(Y)},${W+J*Math.sin(Y)} L${M+B*Math.cos(Y)},${W+B*Math.sin(Y)} A${B},${B} 0 0,0 ${M+B*Math.cos(T)},${W+B*Math.sin(T)} Z`,fill:A},l))}const Z=`wheel-center-${s}`,F=t.map((l,T)=>{const Y=(J+B)/2,A=l*Math.PI/180;return e.jsx("circle",{cx:M+Y*Math.cos(A),cy:W+Y*Math.sin(A),r:T===0?8:6,fill:i?.[T]??Be({h:l,s:.85,v:.9}),stroke:T===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:T===0?3:2},T)});let k=null;if(s==="analogous"||s==="split-complementary"||s==="analogous-complementary"){const l=(J+B)/2,Y=kt(s,g).slice(1).map((A,_)=>{const b=(o+A)*Math.PI/180;return e.jsx("line",{x1:M,y1:W,x2:M+l*Math.cos(b),y2:W+l*Math.sin(b),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${_}`)});k=e.jsx(e.Fragment,{children:Y})}return e.jsxs("svg",{ref:X,className:"nice-palette__wheel",viewBox:`0 0 ${P} ${P}`,width:P,height:P,onPointerDown:oe,onKeyDown:I,role:"slider",tabIndex:x?-1:0,"aria-label":$("colorPalette.baseHue","Base hue"),"aria-valuemin":0,"aria-valuemax":359,"aria-valuenow":Math.round(o),"aria-valuetext":`${Math.round(o)}°`,style:{cursor:x?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:Z,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),ce,e.jsx("circle",{cx:M,cy:W,r:B-2,fill:Be({h:o,s:.6,v:.85})}),e.jsx("circle",{cx:M,cy:W,r:B-2,fill:`url(#${Z})`,opacity:.4}),k,F]})},Qn=({colors:t})=>{const{t:i}=r.useNiceTranslation();if(t.length<2)return null;const o=[];for(let a=0;a<t.length;a++){const s=bt(t[a],"var(--nice-bg-primary, #ffffff)"),g=bt(t[a],"var(--nice-text-primary, #000000)");o.push({a:t[a],b:"var(--nice-bg-primary, #ffffff)",ratio:s,level:jt(s)}),o.push({a:t[a],b:"var(--nice-text-primary, #000000)",ratio:g,level:jt(g)});for(let x=a+1;x<t.length;x++){const $=bt(t[a],t[x]);o.push({a:t[a],b:t[x],ratio:$,level:jt($)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:i("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx("div",{className:"nice-palette__contrast-grid",children:o.map((a,s)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:i("colorPalette.vs","vs")}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[a.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${a.level.toLowerCase().replace("-","")}`,children:a.level})]},s))})]})},ei=({hex:t})=>{const i=pt(t),o=un(i),a=At(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.v*100),"%"]})]})},ti={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous","analogous-complementary":"Analogous + Complementary",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},ni={"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"},ii=["monochromatic","shade-chain","complementary","split-complementary","analogous","analogous-complementary","triadic","tetradic","square","custom"],yn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],xn="nice-palette-custom-schemes";function oi(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(xn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function ai(t){if(!(typeof window>"u"))try{window.localStorage.setItem(xn,JSON.stringify(t))}catch{}}const si=Object.assign(n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:s,onChange:g,minColors:x=1,maxColors:$=8,harmonyMode:P,onHarmonyModeChange:M,distance:W,onDistanceChange:J,preset:B,onPresetChange:I,showWheel:X=!0,showContrast:se=!0,showInfo:oe=!0,showPresets:ce=!0,presets:Z=[],showVariations:F=!0,showRandom:k=!0,variationCount:l=5,label:T,labelPlacement:Y="top",disabled:A,readOnly:_,loading:b,error:C,colorCount:f,shadeStep:S,onShadeStepChange:K,customSchemes:w,onCustomSchemesChange:d,persistCustomSchemes:D=!0,"data-testid":j},h)=>{const c=r.useNiceAccessMode(a,t),p=c==="hidden";c==="disabled"&&(A=!0);const E=_||c==="readOnly",N=r.useControlId(t),{t:m}=r.useNiceTranslation(),R=tt.useNiceDialogs(),[z,ie]=n.useState("analogous-complementary"),[v,ee]=n.useState(30),[U,me]=n.useState(""),[pe,ye]=n.useState(0),[ue,he]=n.useState(.12),[de,ge]=n.useState(null),[ae,ve]=n.useState(()=>w??(D?oi():[])),[_e,te]=n.useState(null),[we,re]=n.useState(!1),[fe,H]=n.useState(null),[q,O]=n.useState(""),G=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),ne=n.useRef(null),le=n.useRef(null),be=P??z,xe=W??v,Se=B??U,Te=S??ue,Me=w??ae;n.useEffect(()=>{!w&&D&&ai(ae)},[ae,w,D]);const ze=n.useCallback(Q=>{ve(Q),d?.(Q)},[d]),qe=n.useCallback(Q=>{ie(Q),M?.(Q)},[M]),Xe=n.useCallback(Q=>{ee(Q),J?.(Q)},[J]),Ve=n.useCallback(Q=>{me(Q),Q&&I?.(Q)},[I]),Ge=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ee=s&&s.length>0?s:Ge,We=Ee[0],$e=n.useMemo(()=>Ue(We),[We]),Je=n.useMemo(()=>ut($e.h,be,xe),[$e.h,be,xe]),Le=n.useCallback((Q,je,Ne,Re,Ye)=>{const gt=f??Ye??de??Ee.length,nt=gt!==void 0?Math.max(x,Math.min($,gt)):void 0;if(je==="shade-chain"){const Fe=nt??Math.max(x,5),Ze=Vt({h:Q,s:$e.s||.7,v:$e.v||.6},Fe,Te);g?.(Ze);return}let it;const ct=je==="custom"&&_e?Me.find(Fe=>Fe.id===_e):null;ct&&ct.angles.length>0?it=ct.angles.map(Fe=>((Q+Fe)%360+360)%360):it=ut(Q,je,Ne);let De;if(Re&&gn[Re]?De=vt(it,Re):De=it.map(Fe=>Be({h:Fe,s:$e.s||.7,v:$e.v||.85})),ct?.lightnessOffsets?.length&&(De=De.map((Fe,Ze)=>{const Pt=ct.lightnessOffsets?.[Ze];if(Pt==null)return Fe;const Ct=Ue(Fe);return Be({h:Ct.h,s:Ct.s,v:Math.max(.05,Math.min(.98,Ct.v+Pt))})})),nt!==void 0){for(;De.length<nt;){const Fe=De[De.length-1]||"#888888",Ze=Ue(Fe);De.push(Be({h:(Ze.h+18)%360,s:Ze.s,v:Ze.v}))}De=De.slice(0,nt)}else{for(;De.length<x;)De.push(De[De.length-1]||"var(--nice-text-secondary, #888888)");De.length>$&&(De=De.slice(0,$))}g?.(De)},[$e.s,$e.v,x,$,g,f,de,Ee.length,Te,_e,Me]),Ae=n.useCallback(Q=>{if(!A){if(be==="custom"){const je=Be({h:Q,s:$e.s||.7,v:$e.v||.85}),Ne=[...Ee];Ne[pe]=je,g?.(Ne);return}Le(Q,be,xe,Se)}},[A,be,xe,Se,Le,$e.s,$e.v,Ee,pe,g]),Oe=n.useCallback(Q=>{if(A||(qe(Q),Q==="custom"))return;const je=kt(Q).length,Ne=je<=1;if(f==null&&!Ne){const Re=Math.max(x,Math.min($,je));ge(Re),Le($e.h,Q,xe,Se,Re)}else Le($e.h,Q,xe,Se)},[A,$e.h,xe,Se,qe,Le,f,x,$]),st=n.useCallback(Q=>{A||(Xe(Q),Le($e.h,be,Q,Se))},[A,$e.h,be,Se,Xe,Le]),u=n.useCallback(Q=>{if(A)return;Ve(Q);const je=ut($e.h,be,xe),Ne=vt(je,Q);g?.(Ne.slice(0,$))},[A,$e.h,be,xe,$,Ve,g]),V=n.useCallback((Q,je)=>{if(A)return;const Ne=[...Ee];Ne[Q]=je,g?.(Ne)},[A,Ee,g]),L=n.useCallback(()=>{if(A||Ee.length>=$)return;const Q=Ue(Ee[Ee.length-1]),je=Be({h:(Q.h+30)%360,s:Q.s,v:Q.v});g?.([...Ee,je])},[A,Ee,$,g]),ke=n.useCallback(Q=>{if(A||Ee.length<=x)return;const je=Ee.filter((Ne,Re)=>Re!==Q);g?.(je),pe>=je.length&&ye(Math.max(0,je.length-1))},[A,Ee,x,g,pe]),Ce=n.useCallback(()=>{if(A)return;const Q=Math.max(x,Math.min($,kt(be).length)),je=fn(be,Q,xe);g?.(je)},[A,x,$,be,xe,g]),Pe=n.useMemo(()=>{if(!F)return[];const Q=Ee[pe]||Ee[0];return hn(Ue(Q),l)},[F,Ee,pe,l]),He=Ee[pe]||Ee[0],Nt=n.useMemo(()=>{const Q=Ue(He);return Be({h:(Q.h+180)%360,s:Q.s,v:Q.v})},[He]);n.useLayoutEffect(()=>{if(!we||!ne.current)return;O(tt.scopeThemeClass(ne.current));const Q=()=>{const je=ne.current?.getBoundingClientRect();if(!je)return;const Ne=600;let Re=je.left;Re+Ne>window.innerWidth-8&&(Re=Math.max(8,window.innerWidth-Ne-8));let Ye=je.bottom+6;Ye>window.innerHeight*.5&&(Ye=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),H({left:Re,top:Ye})};return Q(),window.addEventListener("scroll",Q,!0),window.addEventListener("resize",Q),()=>{window.removeEventListener("scroll",Q,!0),window.removeEventListener("resize",Q)}},[we]),n.useEffect(()=>{if(!we)return;const Q=je=>{const Ne=je.target;ne.current?.contains(Ne)||le.current?.contains(Ne)||(Ne instanceof Element?Ne:Ne?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"], [aria-modal="true"]')||re(!1)};return document.addEventListener("mousedown",Q),()=>{document.removeEventListener("mousedown",Q)}},[we]),r.useOverlayFocus(le,{open:we,modal:!1,onClose:()=>re(!1)});const zt=n.useRef(null);if(r.useRovingFocus(zt,{orientation:"horizontal",itemSelector:".nice-palette__variation-chip"}),p)return null;const Lt=Z.length>0?Z:yn,In=e.jsxs("div",{className:"nice-palette__tab",children:[e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(et.NiceSelect,{label:m("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:A,value:be==="custom"&&_e?`custom:${_e}`:be,onChange:Q=>{const je=Array.isArray(Q)?Q[0]:Q;if(typeof je=="string")if(je.startsWith("custom:")){const Ne=je.slice(7);te(Ne),Oe("custom")}else te(null),Oe(je)},options:[...ii.map(Q=>({value:Q,label:ti[Q]})),...Me.map(Q=>({value:`custom:${Q.id}`,label:Q.name}))],renderOption:(Q,je)=>{const Ne=String(Q.value),Re=Ne.startsWith("custom:"),Ye=Re?Me.find(it=>it.id===Ne.slice(7)):null,gt=Ye?Ye.angles:void 0,nt=Re?"custom":Ne;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:qt(nt,{angles:gt,size:16,count:f})}),e.jsx("span",{style:{fontWeight:je?600:400},children:Q.label})]})}}),be==="shade-chain"&&e.jsx(ot.NiceNumberInput,{label:m("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Te,onChange:Q=>{const je=typeof Q=="number"?Q:Number(Q);Number.isNaN(je)||(he(je),K?.(je),Le($e.h,be,xe,Se))},showStepper:!0,disabled:A}),e.jsx(ot.NiceNumberInput,{label:m("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,x),max:Math.min(12,$),step:1,precision:0,value:f??de??Ee.length,onChange:Q=>{const je=typeof Q=="number"?Q:Number(Q);if(!Number.isFinite(je))return;const Ne=Math.max(Math.max(2,x),Math.min(Math.min(12,$),Math.round(je)));ge(Ne),be==="shade-chain"?g?.(Vt({h:$e.h,s:$e.s||.7,v:$e.v||.6},Ne,Te)):setTimeout(()=>Le($e.h,be,xe,Se),0)},showStepper:!0,disabled:A})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ee.map((Q,je)=>e.jsxs("div",{role:"presentation",className:`nice-palette__swatch-wrapper ${pe===je?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ye(je),onFocus:()=>ye(je),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:Q}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:Q.toUpperCase(),maxLength:7,disabled:A,onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>V(je,Ne.target.value),"aria-label":m("colorPalette.colorN","Color {n}").replace("{n}",String(je+1))}),Ee.length>x&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:Ne=>{Ne.stopPropagation(),ke(je)},disabled:A,"aria-label":m("colorPalette.removeColor","Remove color"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},je)),Ee.length<$&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:L,disabled:A,title:m("colorPalette.addColor","Add color"),children:[e.jsx(r.NiceIcon,{name:"plus",size:14}),e.jsx("span",{children:m("colorPalette.add","Add")})]})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.complementary","Complementary")}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:Nt},title:Nt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:Nt.toUpperCase()})]}),k&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ce,disabled:A,title:m("colorPalette.randomPalette","Random palette"),"aria-label":m("colorPalette.randomPalette","Random palette"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",m("colorPalette.randomPalette2","Random Palette")]})]})})]}),Mn=e.jsx("div",{className:"nice-palette__tab",children:Pe.length>0?e.jsxs("div",{className:"nice-palette__variations",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.tintsShades","Tints & Shades")}),e.jsx("div",{ref:zt,className:"nice-palette__variation-strip",role:"group","aria-label":m("colorPalette.tintsShades","Tints & Shades"),children:Pe.map((Q,je)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:Q},title:Q.toUpperCase(),onClick:()=>{A||V(pe,Q)},onKeyDown:Ne=>{!A&&(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),V(pe,Q))},role:"button","aria-label":Q.toUpperCase()},je))})]}):e.jsx("div",{className:"nice-palette__empty",children:m("colorPalette.noVariationsAvailable","No variations available.")})}),Tn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:Lt.map(Q=>{const je=vt(Je,Q);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${Se===Q?"nice-palette__preset-card--active":""}`,onClick:()=>u(Q),disabled:A,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:je.map((Ne,Re)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:Ne}},Re))}),e.jsx("span",{className:"nice-palette__preset-label",children:ni[Q]})]},Q)})})}),Rn=e.jsxs("div",{className:"nice-palette__tab",children:[oe&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:m("colorPalette.selectedColorInfo","Selected Color Info")}),e.jsx(ei,{hex:He})]}),se&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:m("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx(Qn,{colors:Ee})]})]}),An=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Me.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted)"},children:m("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Me.map(Q=>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:qt("custom",{angles:Q.angles,size:16})}),e.jsx("span",{style:{flex:1},children:Q.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{te(Q.id),Oe("custom")},disabled:A,children:m("colorPalette.use","Use")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>ze(Me.filter(je=>je.id!==Q.id)),disabled:A,"aria-label":m("colorPalette.delete","Delete {name}").replace("{name}",String(Q.name)),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},Q.id)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A,onClick:()=>{const Q=Ue(Ee[0]).h,je=Ee.map(Ne=>(Ue(Ne).h-Q+540)%360-180);R.prompt({title:m("colorPalette.schemeNamePrompt","Scheme name"),defaultValue:`Scheme ${Me.length+1}`}).then(Ne=>{if(!Ne)return;const Re={id:`cs-${Date.now()}`,name:Ne,angles:je};ze([...Me,Re])})},children:m("colorPalette.saveCurrentAsScheme","+ Save current as scheme")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A||Me.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Me,null,2))},children:m("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A,onClick:()=>{R.prompt({title:m("colorPalette.pasteSchemesPrompt","Paste the schemes JSON")}).then(Q=>{if(Q)try{const je=JSON.parse(Q);Array.isArray(je)&&ze(je)}catch{}})},children:m("colorPalette.importJson","Import JSON")})]})]})}),rt=[{id:"colors",label:m("colorPalette.colors","Colors"),content:In}];ce&&Lt.length>0&&rt.push({id:"presets",label:m("colorPalette.presets","Presets"),content:Tn}),F&&rt.push({id:"variations",label:m("colorPalette.variations","Variations"),content:Mn}),(oe||se)&&rt.push({id:"info",label:m("colorPalette.info","Info"),content:Rn}),rt.push({id:"schemes",label:m("colorPalette.schemes","Schemes"),content:An});const Dn=e.jsxs("div",{className:"nice-palette__popup-header",children:[X&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Zn,{hues:Je,colors:Ee,baseHue:$e.h,onBaseHueChange:Ae,mode:be,distance:xe,disabled:A}),(be==="analogous"||be==="split-complementary"||be==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsx("label",{children:m("colorPalette.distance","Distance: {dist}°").replace("{dist}",String(xe))}),e.jsx("input",{type:"range",min:10,max:90,value:xe,onChange:Q=>st(Number(Q.target.value)),disabled:A,className:"nice-palette__distance-slider","aria-label":m("colorPalette.distanceLabel","Distance")})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>re(!1),"aria-label":m("controls.confirm","Confirm"),title:m("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),zn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[Dn,e.jsx(ht.NiceTabs,{tabs:rt,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:h,id:N,className:`nice-field nice-palette-field ${A?"nice-palette--disabled":""} ${Y==="left"?"nice-field--label-left":""} ${b?"nice-field--loading":""} ${C?"nice-field--error":""} ${i||""}`,style:o,"data-testid":j,children:[R.element,T&&e.jsx("label",{htmlFor:N,className:"nice-field__label",children:T}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:ne,className:"nice-palette__field-swatches",role:"button",tabIndex:A||E?-1:0,"aria-haspopup":"dialog","aria-expanded":we,"aria-readonly":E||void 0,"aria-label":m("colorPalette.openStudio","Open palette studio"),onClick:()=>{!A&&!E&&re(Q=>!Q)},onKeyDown:Q=>{!A&&!E&&(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),re(je=>!je))},children:Ee.map((Q,je)=>e.jsx("span",{role:"presentation",className:"nice-palette__field-swatch",style:{background:Q},title:Q.toUpperCase(),onClick:Ne=>{Ne.stopPropagation(),!A&&!E&&(ye(je),re(!0))}},je))}),b&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),we&&fe&&G&&at.createPortal(e.jsx("div",{ref:le,className:`nice-palette__popup${q?` ${q}`:""}`,"data-theme":q==="nice-dark"?"dark":q==="nice-light"?"light":void 0,role:"dialog","aria-label":m("colorPalette.studio","Palette studio"),style:{position:"fixed",left:fe.left,top:fe.top,zIndex:1e3},children:zn}),G)]}),typeof C=="string"&&C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C})]})}),{displayName:"NiceColorPalette"});function Mt(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Tt(t){const i=t.stops.slice().sort((a,s)=>a.position-s.position).map(a=>`${a.color} ${a.position}%`).join(", "),o=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${o}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const a=t.shape||"ellipse",s=t.size||"farthest-corner",g=t.positionX??50,x=t.positionY??50;return`${o}radial-gradient(${a} ${s} at ${g}% ${x}%, ${i})`}case"conic":{const a=t.angle??0,s=t.positionX??50,g=t.positionY??50;return`${o}conic-gradient(from ${a}deg at ${s}% ${g}%, ${i})`}}}function bn(t){const i=t.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const a=i.match(/linear-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(M=>M.trim());let g=90,x=0;const $=s[0].match(/^(\d+)deg$/);$&&(g=parseInt($[1]),x=1);const P=St(s.slice(x));return{type:"linear",angle:g,repeating:o,stops:P}}if(i.includes("radial-gradient")){const a=i.match(/radial-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(x=>x.trim()),g=St(s.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:g.length>=2?g:Mt().stops}}if(i.includes("conic-gradient")){const a=i.match(/conic-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(x=>x.trim()),g=St(s.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:g.length>=2?g:Mt().stops}}return null}function St(t){return t.map((i,o,a)=>{const s=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(s){const g=s[2]?parseFloat(s[2]):o/Math.max(1,a.length-1)*100;return{color:s[1],position:g}}return{color:i,position:o/Math.max(1,a.length-1)*100}})}function ri(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function ci(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],a=[];for(let s=0;s<t;s++)a.push({color:ri(),position:Math.round(s/(t-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:a,shape:o==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:o!=="linear"?Math.round(Math.random()*100):void 0,positionY:o!=="linear"?Math.round(Math.random()*100):void 0}}const jn=[{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}}],li=Object.assign(n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:s,onChange:g,showCssOutput:x=!0,showPresets:$=!0,showEditor:P=!0,showRandom:M=!0,maxStops:W=10,label:J,labelPlacement:B="top",disabled:I,readOnly:X,loading:se,error:oe,errorPlacement:ce="bottom",width:Z,"data-testid":F},k)=>{const l=r.useNiceAccessMode(a,t),T=l==="hidden";l==="disabled"&&(I=!0);const Y=X||l==="readOnly",A=r.useControlId(t),{t:_}=r.useNiceTranslation(),b=s??Mt(),C=n.useMemo(()=>Tt(b),[b]),[f,S]=n.useState(0),[K,w]=n.useState(""),d=n.useRef(null),[D,j]=n.useState(!1),[h,c]=n.useState(null),[p,E]=n.useState(""),m=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),R=n.useRef(null),z=n.useRef(null),ie=typeof Z=="number"?Z:340;n.useLayoutEffect(()=>{if(!D||!R.current)return;E(tt.scopeThemeClass(R.current));const y=()=>{const G=R.current?.getBoundingClientRect();if(!G)return;let ne=G.left;ne+ie>window.innerWidth-8&&(ne=Math.max(8,window.innerWidth-ie-8));let le=G.bottom+6;le>window.innerHeight*.5&&(le=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),c({left:ne,top:le})};return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[D,ie]),n.useEffect(()=>{if(!D)return;const y=G=>{const ne=G.target;R.current?.contains(ne)||z.current?.contains(ne)||(ne instanceof Element?ne:ne?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||j(!1)};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[D]),r.useOverlayFocus(z,{open:D,modal:!1,onClose:()=>j(!1)});const v=n.useCallback(y=>{g?.(y)},[g]),ee=n.useCallback(y=>{I||v({...b,type:y})},[I,b,v]),U=n.useCallback(y=>{I||v({...b,angle:y})},[I,b,v]),me=n.useCallback(y=>{I||v({...b,repeating:y})},[I,b,v]),pe=n.useCallback(y=>{I||v({...b,shape:y})},[I,b,v]),ye=n.useCallback((y,G)=>{if(I)return;const ne=b.stops.map((le,be)=>be===y?{...le,...G}:le);v({...b,stops:ne})},[I,b,v]),ue=n.useRef(!1),he=n.useCallback((y,G)=>{if(I||!d.current)return;y.stopPropagation(),y.preventDefault(),S(G),ue.current=!1;const ne=be=>{if(!d.current)return;ue.current=!0;const xe=d.current.getBoundingClientRect(),Se=Math.round(Math.max(0,Math.min(100,(be.clientX-xe.left)/xe.width*100)));ye(G,{position:Se})},le=()=>{document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",le),document.removeEventListener("pointercancel",le)};document.addEventListener("pointermove",ne),document.addEventListener("pointerup",le),document.addEventListener("pointercancel",le)},[I,ye]),de=n.useCallback(()=>{if(I||b.stops.length>=W)return;const y=b.stops.slice().sort((xe,Se)=>xe.position-Se.position);let G=0,ne=y[0];for(let xe=0;xe<y.length-1;xe++){const Se=y[xe+1].position-y[xe].position;Se>G&&(G=Se,ne=y[xe])}const le=Math.round(ne.position+G/2),be="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");v({...b,stops:[...b.stops,{color:be,position:le}]})},[I,b,W,v]),ge=n.useCallback(y=>{if(I||b.stops.length<=2)return;const G=b.stops.filter((ne,le)=>le!==y);v({...b,stops:G}),f>=G.length&&S(G.length-1)},[I,b,f,v]),ae=(y,G)=>{const ne=b.stops[G];if(I||!ne)return;const le=y.shiftKey?10:1,be=y.key==="ArrowLeft"||y.key==="ArrowDown"?ne.position-le:y.key==="ArrowRight"||y.key==="ArrowUp"?ne.position+le:y.key==="PageDown"?ne.position-10:y.key==="PageUp"?ne.position+10:y.key==="Home"?0:y.key==="End"?100:null;be!==null?(y.preventDefault(),ye(G,{position:Math.max(0,Math.min(100,be))})):(y.key==="Delete"||y.key==="Backspace")&&b.stops.length>2&&(y.preventDefault(),ge(G))},ve=n.useCallback(()=>{if(I)return;const y=2+Math.floor(Math.random()*3);v(ci(y))},[I,v]),_e=n.useCallback(()=>{if(I||!K.trim())return;const y=bn(K);y&&v(y)},[I,K,v]),te=n.useCallback(y=>{if(I||!d.current||b.stops.length>=W)return;const G=y.target;if(ue.current||G.closest(".nice-gradient__stop-marker")){ue.current=!1;return}const ne=d.current.getBoundingClientRect(),le=Math.round((y.clientX-ne.left)/ne.width*100),be="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),xe=[...b.stops,{color:be,position:le}];v({...b,stops:xe}),S(xe.length-1)},[I,b,W,v]),we=n.useMemo(()=>b.stops.slice().sort((y,G)=>y.position-G.position),[b.stops]),re=n.useMemo(()=>`linear-gradient(90deg, ${we.map(y=>`${y.color} ${y.position}%`).join(", ")})`,[we]);if(T)return null;const fe=e.jsxs("div",{className:"nice-gradient__tab",children:[P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${b.type===y?"nice-gradient__type-btn--active":""}`,onClick:()=>ee(y),disabled:I,"aria-pressed":b.type===y,children:y.charAt(0).toUpperCase()+y.slice(1)},y)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:b.repeating??!1,onChange:y=>me(y.target.checked),disabled:I}),_("controls.repeating","Repeating")]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[b.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.angle","Angle: {angle}°").replace("{angle}",String(b.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:b.angle,onChange:y=>U(Number(y.target.value)),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.angle","Angle")}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${b.angle===y?"nice-gradient__angle-btn--active":""}`,onClick:()=>U(y),disabled:I,title:`${y}°`,"aria-label":`${y}°`,"aria-pressed":b.angle===y,children:e.jsx("span",{style:{transform:`rotate(${y}deg)`,display:"inline-flex"},children:e.jsx(r.NiceIcon,{name:"arrow-right",size:14})})},y))})]}),b.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.shape","Shape:")}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(b.shape||"ellipse")===y?"nice-gradient__shape-btn--active":""}`,onClick:()=>pe(y),disabled:I,"aria-pressed":(b.shape||"ellipse")===y,children:y},y))})]}),(b.type==="radial"||b.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.center","Center: {positionX}%, {positionY}%").replace("{positionX}",String(b.positionX??50)).replace("{positionY}",String(b.positionY??50))}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:b.positionX??50,onChange:y=>v({...b,positionX:Number(y.target.value)}),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.centerX","Horizontal center")}),e.jsx("input",{type:"range",min:0,max:100,value:b.positionY??50,onChange:y=>v({...b,positionY:Number(y.target.value)}),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.centerY","Vertical center")})]})]}),b.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.startAngle","Start angle: {angle}°").replace("{angle}",String(b.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:b.angle,onChange:y=>U(Number(y.target.value)),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.startAngle","Start angle")})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{role:"presentation",ref:d,className:"nice-gradient__bar",style:{background:re},onClick:te,children:b.stops.map((y,G)=>e.jsx("div",{className:`nice-gradient__stop-marker ${f===G?"nice-gradient__stop-marker--active":""}`,style:{left:`${y.position}%`},onPointerDown:ne=>he(ne,G),onClick:ne=>{ne.stopPropagation(),S(G),ue.current=!1},onFocus:()=>S(G),onKeyDown:ne=>ae(ne,G),role:"slider",tabIndex:I?-1:0,"aria-label":_("gradient.stop","Stop {n}").replace("{n}",String(G+1)),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":y.position,"aria-valuetext":`${y.color} ${y.position}%`,title:`${y.color} @ ${y.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:y.color}})},G))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:de,disabled:I||b.stops.length>=W,title:_("controls.addStop","Add stop"),"aria-label":_("controls.addStop","Add stop"),children:e.jsx(r.NiceIcon,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:we.map((y,G)=>{const ne=b.stops.indexOf(y);return e.jsxs("div",{role:"presentation",className:`nice-gradient__stop-row ${f===ne?"nice-gradient__stop-row--active":""}`,onClick:()=>S(ne),onFocus:()=>S(ne),children:[e.jsx("input",{type:"color",value:y.color,onChange:le=>ye(ne,{color:le.target.value}),disabled:I,className:"nice-gradient__stop-color","aria-label":_("gradient.stopColor","Stop color")}),e.jsx("input",{type:"text",value:y.color.toUpperCase(),maxLength:7,onChange:le=>ye(ne,{color:le.target.value}),disabled:I,className:"nice-gradient__stop-hex","aria-label":_("gradient.stopHex","Stop color (hex)")}),e.jsx("input",{type:"number",min:0,max:100,value:y.position,onChange:le=>ye(ne,{position:Number(le.target.value)}),disabled:I,className:"nice-gradient__stop-pos","aria-label":_("gradient.stopPosition","Stop position")}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),b.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>ge(ne),disabled:I,"aria-label":_("controls.removeStop","Remove stop"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},ne)})})})]}),M&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:ve,disabled:I,title:_("controls.randomGradient","Random gradient"),"aria-label":_("controls.randomGradient","Random gradient"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",_("controls.randomGradient2","Random Gradient")]})]}),H=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:jn.map((y,G)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{I||v(y.value)},disabled:I,title:y.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Tt(y.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:y.name})]},G))})}),q=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${C};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${C};`),title:_("controls.copyCss","Copy CSS"),"aria-label":_("controls.copyCss","Copy CSS"),children:e.jsx(r.NiceIcon,{name:"clipboard",size:16})})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:_("controls.pasteCssGradientToImport","Paste CSS gradient to import..."),value:K,onChange:y=>w(y.target.value),disabled:I,"aria-label":_("gradient.importCss","CSS gradient to import")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:_e,disabled:I,children:_("controls.import","Import")})]})]}),O=[{id:"editor",label:_("controls.editor","Editor"),content:fe}];return $&&O.push({id:"presets",label:_("controls.presets","Presets"),content:H}),x&&O.push({id:"css",label:"CSS",content:q}),e.jsxs("div",{ref:k,id:A,className:`nice-field nice-gradient-field ${I?"nice-gradient--disabled":""} ${B==="left"?"nice-field--label-left":""} ${se?"nice-field--loading":""} ${oe?"nice-field--error":""} ${ce==="right"?"nice-field--error-right":""} ${i||""}`,style:o,"data-testid":F,children:[J&&e.jsx("label",{htmlFor:A,className:"nice-field__label",children:J}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:R,type:"button",className:"nice-gradient__swatch",style:{background:C},"aria-haspopup":"dialog","aria-expanded":D,"aria-readonly":Y||void 0,"aria-label":_("controls.openGradientEditor","Open gradient editor"),disabled:I,onClick:()=>{!I&&!Y&&j(y=>!y)}}),se&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ce==="right"&&typeof oe=="string"&&oe&&e.jsx("div",{className:"nice-field__error",role:"alert",children:oe}),D&&h&&m&&at.createPortal(e.jsx("div",{ref:z,className:`nice-gradient__popup${p?` ${p}`:""}`,"data-theme":p==="nice-dark"?"dark":p==="nice-light"?"light":void 0,role:"dialog","aria-label":_("controls.gradientEditor","Gradient editor"),style:{position:"fixed",left:h.left,top:h.top,width:Z!=null?typeof Z=="number"?`${Z}px`:Z:340,zIndex:1e3},children:e.jsxs("div",{className:"nice-gradient nice-gradient--studio",children:[e.jsxs("div",{className:"nice-gradient__popup-header",children:[e.jsx("div",{className:"nice-gradient__preview",style:{background:C}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>j(!1),"aria-label":_("controls.confirm","Confirm"),title:_("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),e.jsx(ht.NiceTabs,{tabs:O,variant:"enclosed",size:"sm"})]})}),m)]}),ce!=="right"&&typeof oe=="string"&&oe&&e.jsx("div",{className:"nice-field__error",role:"alert",children:oe})]})}),{displayName:"NiceGradientPicker"}),di=[{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"}],mi=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],ui=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:s,enableImprove:g=!0,enableTranslate:x=!0,enableGenerate:$=!0,toolbar:P,languages:M=di,textStyles:W=mi,onImprove:J,onTranslate:B,onGenerate:I,showAIToolbar:X=!0,value:se,onChange:oe,...ce}=i,Z=n.useRef(null),[F,k]=n.useState(!1),[l,T]=n.useState(!1),[Y,A]=n.useState(!1),[_,b]=n.useState(""),[C,f]=n.useState(""),[S,K]=n.useState("professional"),[w,d]=n.useState(""),[D,j]=n.useState(M[0]?.code||"en"),[h,c]=n.useState(""),[p,E]=n.useState(""),{t:N}=sn.useNiceTranslation(),m=r.useNiceAI(),{improveText:R,translate:z,generateHtml:ie,isLoading:v}=r.useTextImprovement(),ee=a&&m.isConfigured,U=n.useCallback(()=>{const ae=window.getSelection();return ae&&ae.toString().trim()?ae.toString():""},[]),me=n.useCallback(ae=>{const ve=window.getSelection();if(ve&&ve.rangeCount>0){const _e=ve.getRangeAt(0);_e.deleteContents();const te=document.createElement("div");te.innerHTML=ae;const we=document.createDocumentFragment();for(;te.firstChild;)we.appendChild(te.firstChild);if(_e.insertNode(we),Z.current){const re=Z.current.innerHTML;oe?.(re)}}},[oe]),pe=n.useCallback(async(ae="professional")=>{if(!ee||!g)return"";const ve=U();if(!ve)return"";b(ve),K(ae),k(!0),f("");try{const _e=await R(ve,ae);return f(_e),J?.(ve,_e,ae),_e}catch{return f(N("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ee,g,U,R,J,N]),ye=n.useCallback(async ae=>{if(!ee||!x)return"";const ve=U();if(!ve)return"";b(ve),j(ae),T(!0),d("");try{const _e=M.find(we=>we.code===ae)?.label||ae,te=await z(ve,_e);return d(te),B?.(ve,te,ae),te}catch{return d(N("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ee,x,U,z,M,B,N]),ue=n.useCallback(async ae=>{if(!ee||!$||!ae.trim())return"";c(ae),E("");try{const ve=await ie(ae);return E(ve),I?.(ae,ve),ve}catch{return E(N("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ee,$,ie,I,N]),he=n.useCallback(()=>{C&&me(C),k(!1),f("")},[C,me]),de=n.useCallback(()=>{w&&me(w),T(!1),d("")},[w,me]),ge=n.useCallback(()=>{if(p&&Z.current){document.execCommand("insertHTML",!1,p);const ae=Z.current.innerHTML;oe?.(ae)}A(!1),E(""),c("")},[p,oe]);return n.useImperativeHandle(o,()=>({getEditor:()=>Z.current,focus:()=>Z.current?.focus(),getValue:()=>Z.current?.innerHTML||"",setValue:ae=>{Z.current&&(Z.current.innerHTML=ae,oe?.(ae))},getSelection:U,insertHtml:ae=>{document.execCommand("insertHTML",!1,ae),Z.current&&oe?.(Z.current.innerHTML)},improveSelection:pe,translateSelection:ye,generateHtml:ue})),n.useCallback(ae=>{Z.current=ae},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[X&&ee&&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:N("htmlEditorAI.ai","AI")}),v&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:N("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>pe(),disabled:v,title:N("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(r.NiceIcon,{name:"star",size:14})," ",N("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:W.map(({style:ae,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>pe(ae),children:ve},ae))})]}),x&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:v,title:N("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(r.NiceIcon,{name:"globe",size:14})," ",N("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:M.map(({code:ae,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ye(ae),children:ve},ae))})]}),$&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>A(!0),disabled:v,title:N("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(r.NiceIcon,{name:"zap",size:14})," ",N("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(rn.NiceHtmlEditor,{value:se,onChange:oe,toolbar:P,...ce})}),F&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"star",size:16})," ",N("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:W.map(({style:ae,label:ve})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${S===ae?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{K(ae),pe(ae)},children:ve},ae))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>k(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:N("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:N("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:_})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:N("htmlEditorAI.improved","Improved")}),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:he,disabled:!C||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{k(!1),f("")},children:N("htmlEditorAI.cancel","Cancel")})]})]}),l&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"globe",size:16})," ",N("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:D,onChange:ae=>{j(ae.target.value),ye(ae.target.value)},className:"nice-html-editor-ai__language-select",children:M.map(({code:ae,label:ve})=>e.jsx("option",{value:ae,children:ve},ae))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>T(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:N("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:N("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:_})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:M.find(ae=>ae.code===D)?.label||D}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:w})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:de,disabled:!w||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{T(!1),d("")},children:N("htmlEditorAI.cancel","Cancel")})]})]}),Y&&e.jsxs("div",{className:"nice-html-editor-ai__panel nice-html-editor-ai__panel--generate",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"zap",size:16})," ",N("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>{A(!1),E(""),c("")},children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:N("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:h,onChange:ae=>c(ae.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>ue(h),disabled:v||!h.trim(),children:v?N("htmlEditorAI.generating","Generating..."):N("htmlEditorAI.generate","Generate")})]}),p&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:N("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:p}}),e.jsx("h5",{children:N("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:p})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ge,disabled:!p||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{A(!1),E(""),c("")},children:N("htmlEditorAI.cancel","Cancel")})]})]})]})}),pi=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function vn(t){let i=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,a,s)=>`<pre><code class="language-${a}">${s.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,a,s,g)=>{const x=a.split("|").filter(P=>P.trim()).map(P=>`<th>${P.trim()}</th>`).join(""),$=g.trim().split(`
|
|
2
|
-
`).map(P=>`<tr>${P.split("|").filter(W=>W.trim()).map(W=>`<td>${W.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${x}</tr></thead><tbody>${$}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done"><input type="checkbox" checked disabled> $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task"><input type="checkbox" disabled> $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),r=require("@nice2dev/ui-core"),n=require("react"),ot=require("react-dom"),Fe=require("./no-code-B1jzfUF5.cjs"),pt=require("./pickerCommons-CwcCc8Qi.cjs"),tt=require("./devops-cgRBnZVX.cjs"),Ue=require("./NiceForm-BWb4LTQJ.cjs"),an=require("@nice2dev/i18n"),sn=require("./NiceHtmlEditor-BzECmDO3.cjs"),Ie=require("./NiceButton-DzCqkG5a.cjs"),Pt=require("./NiceColorPicker-BLwYNSXJ.cjs"),Et=require("./NiceCodeEditor-DhdjnDLV.cjs"),kt=require("./injectStyleOnce-DeWaxcdf.cjs"),zn=({min:t=0,max:i=100,step:o=1,startValue:a=t,endValue:s=i,onChange:g,showLabels:x=!0,formatLabel:$,valuePlacement:P="none",label:M,error:W,helperText:J,required:B,disabled:I,readOnly:q,loading:se,size:oe="md",id:ce,className:Z,style:F,accessMode:k,showKeyboardHints:l,labelPlacement:T,errorPlacement:Y,labelWidth:A,controlWidth:_})=>{const b=r.useNiceAccessMode(k,ce),C=b==="hidden";(b==="disabled"||b==="readOnly")&&(I=!0);const{t:f}=r.useNiceTranslation(),S=r.useControlId(ce),K=n.useRef(null),w=n.useMemo(()=>[r.COMMON_SHORTCUTS.increment,r.COMMON_SHORTCUTS.decrement,r.COMMON_SHORTCUTS.first,r.COMMON_SHORTCUTS.last,{key:"Tab",description:f("shortcuts.switchThumb","Switch thumb")}],[f]),d=p=>(p-t)/(i-t)*100,D=p=>$?$(p):String(p),j=n.useCallback(p=>{const E=Math.round(p/o)*o;return Math.max(t,Math.min(i,E))},[t,i,o]),h=n.useCallback((p,E)=>{p.preventDefault();const N=K.current;if(!N||I)return;const m=z=>{const ie=N.getBoundingClientRect(),v=Math.max(0,Math.min(1,(z.clientX-ie.left)/ie.width)),ee=j(t+v*(i-t));E==="start"?g?.(Math.min(ee,s),s):g?.(a,Math.max(ee,a))},R=()=>{document.removeEventListener("pointermove",m),document.removeEventListener("pointerup",R)};document.addEventListener("pointermove",m),document.addEventListener("pointerup",R)},[t,i,j,a,s,g,I]),c=(p,E)=>{if(I||q)return;const N=E==="start"?a:s,m=E==="start"?t:a,R=E==="start"?s:i,z=Math.max(o,(i-t)/10),ie=p.key==="ArrowRight"||p.key==="ArrowUp"?N+o:p.key==="ArrowLeft"||p.key==="ArrowDown"?N-o:p.key==="PageUp"?N+z:p.key==="PageDown"?N-z:p.key==="Home"?m:p.key==="End"?R:null;if(ie===null)return;p.preventDefault();const v=Math.max(m,Math.min(R,j(ie)));E==="start"?g?.(v,s):g?.(a,v)};return C?null:e.jsxs("div",{className:`nice-field nice-field--${oe} nice-field--rangeslider ${T==="left"?"nice-field--label-left":""} ${Y==="right"?"nice-field--error-right":""} ${W?"nice-field--error":""} ${se?"nice-field--loading":""} ${Z||""}`,style:{...F,...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},..._!=null&&{"--nice-field-control-width":typeof _=="number"?`${_}px`:_}},"aria-busy":se||void 0,children:[(M||P==="right"&&T!=="left")&&(T!=="left"?e.jsxs("div",{className:"nice-range-slider__header",children:[M?e.jsx("label",{className:"nice-field__label",htmlFor:S,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:w,size:"sm"})]})}):e.jsx("span",{}),P==="right"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--header",children:[D(a)," – ",D(s)]})]}):M&&e.jsx("label",{className:"nice-field__label",htmlFor:S,children:e.jsxs("span",{className:"nice-field__label-text",children:[M,B&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:w,size:"sm"})]})})),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-range-slider__stack",children:[e.jsxs("div",{className:`nice-range-slider ${x?"nice-range-slider--with-labels":""} ${M?"nice-range-slider--has-field-label":""}`,ref:K,children:[e.jsx("div",{className:"nice-range-slider__track",children:e.jsx("div",{className:"nice-range-slider__fill",style:{left:`${d(a)}%`,width:`${d(s)-d(a)}%`}})}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(a)}%`},onPointerDown:p=>q?void 0:h(p,"start"),onKeyDown:p=>c(p,"start"),role:"slider","aria-label":f("rangeSlider.min","Minimum"),"aria-valuemin":t,"aria-valuemax":s,"aria-valuenow":a,"aria-valuetext":D(a),"aria-disabled":I||void 0,"aria-readonly":q||void 0,tabIndex:I?-1:0,id:S}),e.jsx("div",{className:"nice-range-slider__thumb",style:{left:`${d(s)}%`},onPointerDown:p=>q?void 0:h(p,"end"),onKeyDown:p=>c(p,"end"),role:"slider","aria-label":f("rangeSlider.max","Maximum"),"aria-valuemin":a,"aria-valuemax":i,"aria-valuenow":s,"aria-valuetext":D(s),"aria-disabled":I||void 0,"aria-readonly":q||void 0,tabIndex:I?-1:0})]}),x&&e.jsxs("div",{className:"nice-range-slider__values",children:[e.jsx("span",{className:"nice-range-slider__values-start",style:{left:`${d(a)}%`},children:D(a)}),e.jsx("span",{className:"nice-range-slider__values-end",style:{left:`${d(s)}%`},children:D(s)})]}),P==="bottom"&&e.jsxs("div",{className:"nice-range-slider__value nice-range-slider__value--bottom",children:[D(a)," – ",D(s)]})]}),P==="right"&&T==="left"&&e.jsxs("span",{className:"nice-range-slider__value nice-range-slider__value--inline",children:[D(a)," – ",D(s)]}),se&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),Y==="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),Y==="right"&&!W&&J&&e.jsx("div",{className:"nice-field__helper",children:J})]}),Y!=="right"&&W&&e.jsx("div",{className:"nice-field__error",role:"alert",children:W}),Y!=="right"&&!W&&J&&e.jsx("div",{className:"nice-field__helper",children:J})]})},Ln={xxs:36,xs:48,sm:64,md:80,lg:100,xl:128,xxl:160,small:64,medium:80,large:100},gt=6,dt=135,rn=405,ct=rn-dt;function $t(t,i,o,a){const s=(a-90)*(Math.PI/180);return{x:t+o*Math.cos(s),y:i+o*Math.sin(s)}}function Ot(t,i,o,a,s){const g=$t(t,i,o,a),x=$t(t,i,o,s),$=s-a>180?1:0;return`M ${g.x} ${g.y} A ${o} ${o} 0 ${$} 1 ${x.x} ${x.y}`}const Pn=Object.assign(n.forwardRef(({value:t=0,onChange:i,min:o=0,max:a=100,step:s=1,showValue:g=!0,valueTemplate:x="{value}",label:$,helperText:P,error:M,required:W,disabled:J,readOnly:B,size:I="md",name:q,id:se,className:oe,style:ce,labelPlacement:Z="top",errorPlacement:F,labelWidth:k,controlWidth:l,loading:T,isLabelCentered:Y=!0,...A},_)=>{const b=r.useControlId(se),C=n.useRef(!1),f=n.useRef(null),S=typeof I=="number"?I:Ln[I],K=S/2,w=S/2,d=(S-gt*2)/2,D=a>o?(t-o)/(a-o):0,j=dt+D*ct,h=n.useCallback(m=>{let R=m-dt;R<0&&(R+=360),R>ct&&(R=R-ct<360-R?ct:0);const z=Math.max(0,Math.min(1,R/ct)),ie=o+z*(a-o),v=Math.round(ie/s)*s;return Math.max(o,Math.min(a,v))},[o,a,s]),c=n.useCallback(m=>{if(J||B)return;const R=f.current;if(!R)return;const z=R.getBoundingClientRect(),ie=m.clientX-z.left-z.width/2,v=m.clientY-z.top-z.height/2;let ee=Math.atan2(ie,-v)*(180/Math.PI);ee<0&&(ee+=360);const U=h(ee);i?.(U)},[h,J,B,i]);n.useEffect(()=>{const m=z=>{C.current&&c(z)},R=()=>{C.current=!1};return window.addEventListener("pointermove",m),window.addEventListener("pointerup",R),()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",R)}},[c]);const p=n.useCallback(m=>{if(J||B)return;let R=t;const z=Math.max(s,(a-o)/10);m.key==="ArrowUp"||m.key==="ArrowRight"?(m.preventDefault(),R=Math.min(a,t+s)):m.key==="ArrowDown"||m.key==="ArrowLeft"?(m.preventDefault(),R=Math.max(o,t-s)):m.key==="PageUp"||m.key==="PageDown"?(m.preventDefault(),R=Math.max(o,Math.min(a,t+(m.key==="PageUp"?z:-z)))):(m.key==="Home"||m.key==="End")&&(m.preventDefault(),R=m.key==="Home"?o:a),R!==t&&i?.(R)},[t,i,o,a,s,J,B]),E=(x||"{value}").replace("{value}",String(t)),N=$t(K,w,d,j);return e.jsxs("div",{className:`nice-field nice-knob-field nice-knob-field--err-${F||"bottom"} nice-field--${typeof I=="string"?I:"md"} ${T?"nice-field--loading":""} ${oe||""}`,style:{...ce,...k!=null&&{"--nice-field-label-width":typeof k=="number"?`${k}px`:k},...l!=null&&{"--nice-field-control-width":typeof l=="number"?`${l}px`:l}},"aria-busy":T||void 0,...A,children:[e.jsxs("div",{className:`nice-knob-field__inner nice-knob-field--${Z} ${Y?"nice-knob-field--label-centered":""}`,children:[$&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${W?"nice-field__label--required":""}`,children:$}),e.jsx("div",{className:"nice-field__control",children:e.jsxs("div",{ref:m=>{f.current=m,typeof _=="function"?_(m):_&&(_.current=m)},className:`nice-knob nice-knob--${I} ${J?"nice-knob--disabled":""} ${M?"nice-knob--error":""}`,role:"slider",id:b,tabIndex:J?-1:0,"aria-valuenow":t,"aria-valuemin":o,"aria-valuemax":a,"aria-disabled":J,"aria-invalid":!!M,onPointerDown:m=>{J||B||(C.current=!0,c(m))},onKeyDown:p,children:[e.jsxs("svg",{width:S,height:S,viewBox:`0 0 ${S} ${S}`,children:[e.jsx("path",{d:Ot(K,w,d,dt,rn),fill:"none",stroke:"var(--nice-border-color, #d1d5db)",strokeWidth:gt,strokeLinecap:"round"}),D>0&&e.jsx("path",{d:Ot(K,w,d,dt,j),fill:"none",stroke:"var(--nice-primary, #3b82f6)",strokeWidth:gt,strokeLinecap:"round"}),e.jsx("circle",{cx:N.x,cy:N.y,r:gt,fill:"var(--nice-primary, #3b82f6)"})]}),g&&e.jsx("span",{className:"nice-knob__value",children:E}),q&&e.jsx("input",{type:"hidden",name:q,value:t}),T&&e.jsx("span",{className:"nice-knob__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]})})]}),M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),!M&&P&&e.jsx("div",{className:"nice-field__helper",children:P})]})}),{displayName:"NiceKnob"}),On=({options:t,value:i,defaultValue:o,onChange:a,searchable:s=!0,clearable:g,loading:x,placeholder:$,label:P,error:M,helperText:W,required:J,disabled:B,readOnly:I,size:q="md",id:se,className:oe,style:ce,data:Z,columns:F,valueField:k="id",displayField:l,dropdownWidth:T,menuGap:Y,labelPlacement:A,errorPlacement:_,labelWidth:b,controlWidth:C})=>{const f=B||I||x,S=r.useControlId(se),{t:K}=r.useNiceTranslation(),[w,d]=r.useControllableState({value:i,defaultValue:o,fallbackValue:"",onChange:a,componentName:"NiceLookup"}),[D,j]=n.useState(!1),[h,c]=n.useState(""),p=n.useRef(null),E=n.useRef(null),{popupRef:N,coords:m,ready:R,themeClass:z,portalTarget:ie}=Fe.useAnchoredPopup(D,E,()=>j(!1)),v=!!(Z&&F&&F.length>0),ee=l??(F&&F[0]?.key),U=n.useMemo(()=>!v||!Z?[]:Z.map(re=>({value:String(re[k]??""),label:ee?String(re[ee]??""):""})),[v,Z,k,ee]),me=n.useMemo(()=>v?U:t??[],[v,U,t]),pe=me.find(re=>String(re.value)===w),ye=n.useMemo(()=>{if(!v||!Z)return[];if(!h)return Z;const re=h.toLowerCase();return Z.filter(fe=>F.some(H=>String(fe[H.key]??"").toLowerCase().includes(re)))},[v,Z,F,h]),ue=n.useMemo(()=>{if(v||!h)return me;const re=h.toLowerCase();return me.filter(fe=>fe.label.toLowerCase().includes(re))},[me,h,v]),he=v?ye:ue,{activeIndex:de,setActiveIndex:ge,handleKeyDown:ae}=pt.useListKeyboardNav(he,{open:D,onSelect:re=>{const fe=String(v?re[k]??"":re.value);d(fe),j(!1),c("")},onClose:()=>j(!1),onOpen:()=>!f&&j(!0),intentRef:N}),_e=`${n.useId()}-listbox`,te=re=>`${_e}-opt-${re}`,we=D&&he.length>0?te(de):void 0;return n.useLayoutEffect(()=>{we&&document.getElementById(we)?.scrollIntoView?.({block:"nearest"})},[we]),e.jsxs("div",{className:`nice-field nice-field--lookup nice-field--${q} ${M?"nice-field--error":""} ${A==="left"?"nice-field--label-left":""} ${_==="right"&&(M||W)?"nice-field--error-right":""} ${x?"nice-field--loading":""} ${B?"nice-field--disabled":""} ${oe||""}`,style:{...C!=null&&{"--nice-field-control-width":typeof C=="number"?`${C}px`:C},...b!=null&&{"--nice-field-label-width":typeof b=="number"?`${b}px`:b},...Y!=null&&{"--nice-dropdown-gap":`${Y}px`},...ce},"aria-busy":x||void 0,ref:p,children:[P&&e.jsxs("label",{className:"nice-field__label",htmlFor:S,children:[P,J&&e.jsx("span",{className:"nice-field__required",children:"*"})]}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{className:"nice-field__input-wrap",ref:E,children:[e.jsxs("button",{type:"button",id:S,className:`nice-select__trigger ${B?"nice-select__trigger--disabled":""}`,onClick:()=>!f&&j(!D),onKeyDown:ae,disabled:B,"aria-readonly":I||void 0,role:"combobox","aria-haspopup":"listbox","aria-expanded":D,"aria-controls":D?_e:void 0,"aria-activedescendant":s?void 0:we,children:[e.jsx("span",{children:pe?.label||$||K("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[g&&w&&!B&&!I&&e.jsx("span",{onKeyDown:r.clickOnActivationKey,className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":K("controls.clear","Clear"),onClick:re=>{re.stopPropagation(),d("")},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:`nice-select__arrow${I?" nice-select__arrow--hidden":""}`,children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),D&&m&&ie&&ot.createPortal(e.jsxs("div",{ref:N,className:`nice-dropdown nice-lookup__dropdown${z?` ${z}`:""}`,"data-theme":z==="nice-dark"?"dark":z==="nice-light"?"light":void 0,style:{position:"fixed",top:m.top,left:m.left,zIndex:1e3,marginTop:"var(--nice-dropdown-gap, 0px)",background:"var(--nice-bg-primary)",border:"1px solid var(--nice-border-color)",borderRadius:"var(--nice-radius-md)",boxShadow:"0 4px 16px var(--nice-overlay-15, rgba(0, 0, 0, 0.15))",minWidth:m.width,width:T!=null?typeof T=="number"?`${T}px`:T:v?"max-content":m.width,opacity:R?1:0,pointerEvents:R?void 0:"none"},children:[s&&e.jsx("div",{className:"nice-dropdown__search",style:{padding:6},children:e.jsx("input",{type:"text",value:h,onChange:re=>{c(re.target.value),ge(0)},onKeyDown:ae,placeholder:K("controls.search","Search..."),"aria-label":K("controls.search","Search..."),"aria-controls":_e,"aria-activedescendant":we,"aria-autocomplete":"list",autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid var(--nice-border-color)",borderRadius:4,background:"var(--nice-bg-primary)",color:"var(--nice-text-primary)"}})}),v?e.jsxs("table",{className:"nice-lookup__grid",role:"listbox",id:_e,style:{width:"100%",borderCollapse:"collapse",color:"var(--nice-text-primary)"},children:[e.jsx("thead",{children:e.jsx("tr",{children:F.map(re=>e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontSize:12,fontWeight:600,color:"var(--nice-text-secondary)",background:"var(--nice-bg-secondary)",borderBottom:"1px solid var(--nice-border-color)",width:re.width!=null?typeof re.width=="number"?`${re.width}px`:re.width:void 0},children:re.header},re.key))})}),e.jsx("tbody",{children:ye.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:F.length,style:{padding:12,textAlign:"center",color:"var(--nice-text-muted)"},children:K("controls.noResults","No results")})}):ye.map((re,fe)=>{const H=String(re[k]??""),X=H===w,O=fe===de;return e.jsx("tr",{id:te(fe),role:"option","aria-selected":X,onClick:()=>{d(H),j(!1),c("")},style:{cursor:"pointer",background:X||O?"var(--nice-hover-bg)":"transparent"},onMouseEnter:()=>ge(fe),children:F.map(y=>e.jsx("td",{style:{padding:"6px 10px",fontSize:13,borderBottom:"1px solid var(--nice-border-color)"},children:String(re[y.key]??"")},y.key))},H)})})]}):e.jsx("ul",{className:"nice-dropdown__list",role:"listbox",id:_e,style:{listStyle:"none",margin:0,padding:4,maxHeight:240,overflowY:"auto",position:"static",background:"transparent",border:"none",borderRadius:0,boxShadow:"none"},children:ue.length===0?e.jsx("li",{className:"nice-dropdown__empty",style:{padding:8,color:"var(--nice-text-muted)"},children:K("controls.noResults","No results")}):ue.map((re,fe)=>e.jsx("li",{id:te(fe),role:"option",className:`nice-dropdown__option ${String(re.value)===w?"nice-dropdown__option--selected":""} ${fe===de?"nice-dropdown__option--active":""}`,onClick:()=>{d(String(re.value)),j(!1),c("")},onMouseEnter:()=>ge(fe),"aria-selected":String(re.value)===w,children:re.label},String(re.value)))})]}),ie)]}),x&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),_==="right"&&M&&e.jsx("div",{className:"nice-field__error",role:"alert",children:M}),_==="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]}),_!=="right"&&M&&e.jsx("div",{className:"nice-field__error",children:M}),_!=="right"&&!M&&W&&e.jsx("div",{className:"nice-field__hint",children:W})]})},Bn=[];function Bt(t){const i=[],o=a=>{for(const s of a)i.push(s),s.children&&o(s.children)};return o(t),i}function cn(t,i){const o=i.toLowerCase();return t.reduce((a,s)=>{const g=s.children?cn(s.children,i):[];return(s.label.toLowerCase().includes(o)||g.length>0)&&a.push({...s,children:g.length>0?g:s.children}),a},[])}const ln=({node:t,level:i,selectedKeys:o,expandedKeys:a,onToggleExpand:s,onSelect:g,selectableLeafsOnly:x,maxDepth:$})=>{const{t:P}=r.useNiceTranslation(),M=typeof $=="number"?Math.min(10,Math.max(1,$)):1/0,J=!(i+1>=M)&&t.children&&t.children.length>0,B=a.has(t.key),I=o.has(t.key),q=!J,se=!t.disabled&&(!x||q),oe=Math.min(i+1,10),ce={paddingLeft:i*16+14,"--nice-row-bg":`var(--nice-tree-level-${oe}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${oe}-text, inherit)`,"--nice-row-hover-bg":`var(--nice-tree-level-${oe}-hover-bg, var(--nice-bg-secondary, #f3f4f6))`,"--nice-row-active-bg":`var(--nice-tree-level-${oe}-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 ${I?"nice-tree-select__node--selected":""} ${t.disabled?"nice-tree-select__node--disabled":""}`,style:ce,"data-nice-depth":oe,onClick:()=>{t.disabled||(J?s(t.key):se&&g(t.key))},role:"treeitem","aria-level":i+1,"aria-selected":I,"aria-expanded":J?B:void 0,"aria-disabled":t.disabled,"data-key":String(t.key),children:[J?e.jsx("button",{type:"button",className:"nice-tree-select__toggle-btn",tabIndex:-1,onClick:Z=>{Z.stopPropagation(),s(t.key)},"aria-label":P("controls.toggle","Toggle"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:12,style:{transform:B?"rotate(90deg)":"none",transition:"transform 0.15s"}})}):e.jsx("span",{style:{width:12,display:"inline-block"}}),e.jsx("span",{className:"nice-tree-select__node-label",children:t.label})]}),J&&B&&t.children.map(Z=>e.jsx(ln,{node:Z,level:i+1,selectedKeys:o,expandedKeys:a,onToggleExpand:s,onSelect:g,selectableLeafsOnly:x,maxDepth:$},Z.key))]})},Hn=Object.assign(n.forwardRef(({nodes:t=Bn,value:i,onChange:o,multiple:a=!1,searchable:s=!1,placeholder:g,selectableLeafsOnly:x=!1,clearable:$=!1,maxDepth:P,label:M,helperText:W,error:J,required:B,disabled:I,readOnly:q,size:se="md",name:oe,id:ce,className:Z,style:F,controlWidth:k,menuGap:l,labelPlacement:T,errorPlacement:Y,labelWidth:A,..._},b)=>{const{t:C}=r.useNiceTranslation(),f=r.useControlId(ce),[S,K]=n.useState(!1),[w,d]=n.useState(""),[D,j]=n.useState(new Set),h=n.useRef(null),{popupRef:c,coords:p,ready:E,themeClass:N,portalTarget:m}=Fe.useAnchoredPopup(S,h,()=>K(!1)),R=n.useMemo(()=>i==null?new Set:new Set(Array.isArray(i)?i:[i]),[i]),z=n.useMemo(()=>w?cn(t,w):t,[t,w]),ie=n.useMemo(()=>{const he=Bt(t);return Array.from(R).map(de=>he.find(ge=>ge.key===de)?.label).filter(Boolean)},[R,t]),v=n.useCallback(he=>{j(de=>{const ge=new Set(de);return ge.has(he)?ge.delete(he):ge.add(he),ge})},[]),ee=n.useCallback(he=>{if(a){const de=new Set(R);de.has(he)?de.delete(he):de.add(he),o?.(Array.from(de))}else o?.(he),K(!1)},[a,R,o]),U=n.useCallback(he=>{he.stopPropagation(),o?.(a?[]:"")},[o,a]),me=n.useRef(null),pe=`${f}-tree`;r.useTreeFocus(me,{onToggle:(he,de)=>{const ge=Bt(z).find(ae=>String(ae.key)===he.dataset.key);ge&&D.has(ge.key)!==de&&v(ge.key)}});const ye=n.useCallback(()=>(me.current?.querySelector('[role="treeitem"][tabindex="0"]')??me.current?.querySelector('[role="treeitem"]'))?.focus(),[]),ue=!!p;return n.useEffect(()=>{S&&ue&&!s&&ye()},[S,ue,s,ye]),e.jsxs("div",{className:`nice-field nice-field--${se}${T?` nice-field--label-${T}`:""}${Y==="right"?" nice-field--error-right":""} ${Z||""}`,style:{width:"fit-content",maxWidth:"100%",...l!=null&&{"--nice-dropdown-gap":`${l}px`},...A!=null&&{"--nice-field-label-width":typeof A=="number"?`${A}px`:A},...F},..._,children:[M&&e.jsx("label",{htmlFor:f,className:`nice-field__label ${B?"nice-field__label--required":""}`,children:M}),e.jsxs("div",{ref:h,className:"nice-tree-select",style:{position:"relative",width:k!=null&&k!==""?typeof k=="number"?`${k}px`:k:"var(--nice-field-control-width, 220px)"},children:[e.jsxs("div",{ref:b,id:f,className:`nice-input nice-input--${se} ${J?"nice-input--error":""} ${I?"nice-input--disabled":""} ${q?"nice-input--readonly":""}`,role:"combobox","aria-expanded":S,"aria-haspopup":"tree","aria-controls":S?pe:void 0,"aria-invalid":!!J,tabIndex:I?-1:0,onClick:()=>!I&&!q&&K(!S),onKeyDown:he=>{(he.key==="Enter"||he.key===" "||he.key==="ArrowDown"||he.key==="ArrowUp")&&!I&&!q&&(he.preventDefault(),S?ye():K(!0))},children:[e.jsx("span",{className:"nice-tree-select__display",children:ie.length>0?ie.join(", "):e.jsx("span",{className:"nice-tree-select__placeholder",children:g??C("controls.select","Select...")})}),$&&R.size>0&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:U,"aria-label":C("controls.clear","Clear"),children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-tree-select__arrow",style:{transform:S?"rotate(180deg)":"none",transition:"transform 0.15s"},children:e.jsx(r.NiceIcon,{name:"chevron-down",size:14})})]}),S&&p&&m&&ot.createPortal(e.jsxs("div",{ref:c,className:`nice-tree-select__dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",left:p.left,top:p.top,width:p.width,minWidth:p.width,zIndex:1e3,opacity:E?1:0,pointerEvents:E?void 0:"none"},children:[s&&e.jsx("div",{className:"nice-select__search",onClick:he=>he.stopPropagation(),role:"presentation",children:e.jsx("input",{type:"text",placeholder:C("controls.search","Search..."),"aria-label":C("controls.search","Search..."),"aria-controls":pe,value:w,onChange:he=>d(he.target.value),onKeyDown:he=>{he.key==="ArrowDown"&&(he.preventDefault(),ye())},autoFocus:!0})}),e.jsx("div",{ref:me,id:pe,className:"nice-tree-select__list",role:"tree","aria-label":M||g||C("controls.select","Select..."),"aria-multiselectable":a||void 0,children:z.length===0?e.jsx("div",{className:"nice-tree-select__empty",children:C("controls.noResults","No results")}):z.map(he=>e.jsx(ln,{node:he,level:0,selectedKeys:R,expandedKeys:D,onToggleExpand:v,onSelect:ee,selectableLeafsOnly:x,maxDepth:P},he.key))})]}),m)]}),oe&&e.jsx("input",{type:"hidden",name:oe,value:Array.isArray(i)?i.join(","):i??""}),J&&e.jsx("div",{id:`${f}-error`,className:"nice-field__error",role:"alert",children:J}),!J&&W&&e.jsx("div",{id:`${f}-helper`,className:"nice-field__helper",children:W})]})}),{displayName:"NiceTreeSelect"}),Fn=({displayValue:t,placeholder:i,clearable:o,children:a,onClear:s,open:g,onOpenChange:x,dropdownWidth:$,searchable:P=!0,onSearch:M,searchPlaceholder:W,label:J,error:B,helperText:I,required:q,disabled:se,size:oe="md",id:ce,className:Z,style:F,accessMode:k,showKeyboardHints:l,displayStyle:T})=>{r.useComponentDisplayStyle("input",T),r.useComponentDisplayClass("input",T);const Y=r.useNiceAccessMode(k,ce),A=Y==="hidden";(Y==="disabled"||Y==="readOnly")&&(se=!0);const _=r.useControlId(ce),{t:b}=r.useNiceTranslation(),[C,f]=n.useState(!1),[S,K]=n.useState(""),w=n.useRef(null),d=n.useRef(null),D=g??C,j=n.useMemo(()=>[{key:"Enter",description:b("shortcuts.openDropdown","Open dropdown")},r.COMMON_SHORTCUTS.cancel],[b]),h=R=>{x?x(R):f(R)},{popupRef:c,coords:p,ready:E,themeClass:N,portalTarget:m}=Fe.useAnchoredPopup(D,d,()=>h(!1));return A?null:e.jsxs("div",{className:`nice-field nice-field--${oe} ${B?"nice-field--error":""} ${Z||""}`,style:F,ref:w,children:[J&&e.jsxs("label",{className:"nice-field__label",htmlFor:_,children:[J,q&&e.jsx("span",{className:"nice-field__required",children:"*"}),l&&e.jsx(r.NiceKeyboardHint,{shortcuts:j,size:"sm"})]}),e.jsxs("div",{className:"nice-field__input-wrap",ref:d,children:[e.jsxs("button",{type:"button",id:_,className:"nice-select__trigger",onClick:()=>!se&&h(!D),disabled:se,children:[e.jsx("span",{children:t||i||b("controls.select","Select...")}),e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[o&&t&&!se&&e.jsx("span",{className:"nice-input__clear",role:"button",tabIndex:0,"aria-label":b("controls.clear","Clear"),onClick:R=>{R.stopPropagation(),s?.()},onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),R.stopPropagation(),s?.())},children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("span",{className:"nice-select__arrow",children:e.jsx(r.NiceIcon,{name:"chevron-down",size:16})})]})]}),D&&p&&m&&ot.createPortal(e.jsxs("div",{ref:c,className:`nice-dropdown${N?` ${N}`:""}`,"data-theme":N==="nice-dark"?"dark":N==="nice-light"?"light":void 0,style:{position:"fixed",left:p.left,top:p.top,width:$??p.width,minWidth:$??p.width,zIndex:1e3,maxHeight:320,overflowY:"auto",opacity:E?1:0,pointerEvents:E?void 0:"none"},children:[P&&M&&e.jsx("div",{className:"nice-select__search",children:e.jsx("input",{type:"text",value:S,onChange:R=>{K(R.target.value),M(R.target.value)},placeholder:W??b("controls.search","Search..."),autoFocus:!0})}),a]}),m)]}),B&&e.jsx("div",{className:"nice-field__error",children:B}),I&&!B&&e.jsx("div",{className:"nice-field__hint",children:I})]})},Kn=[],Un=[];function et(t,i){return String(t[i])}const Yn={xxs:10,xs:12,sm:12,md:14,lg:18,xl:22,xxl:26},Xn=Object.assign(n.forwardRef(({source:t=Kn,target:i=Un,onChange:o,keyField:a="id",labelField:s="label",renderItem:g,filterable:x=!1,searchable:$,groupBy:P,sortable:M=!1,bulkActions:W=!0,maxRight:J,sourceHeader:B,targetHeader:I,disabled:q=!1,size:se="md",className:oe,style:ce,id:Z,...F},k)=>{const{t:l}=r.useNiceTranslation(),T=Yn[se]??14,[Y,A]=n.useState(new Set),[_,b]=n.useState(new Set),[C,f]=n.useState(""),[S,K]=n.useState(""),[w,d]=n.useState(null),D=n.useRef(null),j=n.useRef(null),h={orientation:"vertical",typeahead:!0,pageSize:10};r.useRovingFocus(D,h),r.useRovingFocus(j,h);const c=n.useCallback((v,ee,U)=>{ee(me=>{const pe=new Set(me);return pe.has(U)?pe.delete(U):pe.add(U),pe})},[]),p=n.useCallback(()=>{const v=t.filter(pe=>Y.has(et(pe,a))),ee=t.filter(pe=>!Y.has(et(pe,a))),U=typeof J=="number"?v.slice(0,Math.max(0,J-i.length)):v,me=v.slice(U.length);o([...ee,...me],[...i,...U]),A(new Set)},[t,i,Y,a,o,J]),E=n.useCallback(()=>{const v=i.filter(U=>_.has(et(U,a))),ee=i.filter(U=>!_.has(et(U,a)));o([...t,...v],ee),b(new Set)},[t,i,_,a,o]),N=n.useCallback(()=>{if(typeof J=="number"){const v=Math.max(0,J-i.length),ee=t.slice(0,v),U=t.slice(v);o(U,[...i,...ee])}else o([],[...i,...t]);A(new Set)},[t,i,o,J]),m=n.useCallback(()=>{o([...t,...i],[]),b(new Set)},[t,i,o]),R=(v,ee)=>{if(!ee)return v;const U=ee.toLowerCase();return v.filter(me=>String(me[s]).toLowerCase().includes(U))},z=W===!1?{moveAll:!1,removeAll:!1}:W===!0||W===void 0?{moveAll:!0,removeAll:!0}:{moveAll:W.moveAll??!0,removeAll:W.removeAll??!0},ie=(v,ee,U,me,pe,ye,ue,he)=>{let de=R(v,me);M||(de=[...de].sort((re,fe)=>String(re[s]).localeCompare(String(fe[s]),void 0,{numeric:!0,sensitivity:"base"})));const ge=$===!0||x&&$===void 0?"both":$??!1,ae=ge==="both"||ge==="left"&&ue==="left"||ge==="right"&&ue==="right",ve=(()=>{if(!P)return[{label:"",items:de}];const re=new Map;for(const fe of de){const H=String(P(fe));let X=re.get(H);X||(X=[],re.set(H,X)),X.push(fe)}return[...re.entries()].map(([fe,H])=>({label:fe,items:H}))})(),_e=(re,fe)=>{re.dataTransfer.setData("text/plain",fe),re.dataTransfer.effectAllowed="move"},te=(re,fe)=>{if(re.preventDefault(),!M)return;const H=re.currentTarget.getBoundingClientRect(),X=re.clientY<H.top+H.height/2;d(O=>O&&O.side===ue&&O.key===fe&&O.before===X?O:{side:ue,key:fe,before:X})},we=(re,fe)=>{re.preventDefault();const H=w?.before??!1;d(null);const X=re.dataTransfer.getData("text/plain");if(!X||!M)return;const y=[...ue==="right"?i:t],G=y.findIndex(xe=>et(xe,a)===X),ne=y.findIndex(xe=>et(xe,a)===fe);if(G===-1||ne===-1||X===fe)return;let le=H?ne:ne+1;const[be]=y.splice(G,1);G<le&&(le-=1),y.splice(le,0,be),o(ue==="right"?t:y,ue==="right"?y:i)};return e.jsxs("div",{className:"nice-picklist__panel",children:[ye&&e.jsx("div",{className:"nice-picklist__header",children:ye}),ae&&e.jsx("div",{className:"nice-picklist__filter",children:e.jsx("input",{className:"nice-input__native",type:"text",size:1,placeholder:l("controls.search","Search..."),value:me,onChange:re=>pe(re.target.value)})}),e.jsxs("div",{className:"nice-picklist__list",role:"listbox","aria-multiselectable":"true","aria-label":typeof ye=="string"?ye:void 0,ref:he,children:[ve.map(re=>e.jsxs(n.Fragment,{children:[re.label&&e.jsx("div",{className:"nice-picklist__group-header",role:"presentation",children:re.label}),re.items.map(fe=>{const H=et(fe,a),X=ee.has(H),y=w&&w.side===ue&&w.key===H?w.before?"nice-picklist__item--drop-before":"nice-picklist__item--drop-after":"";return e.jsxs("div",{className:`nice-picklist__item ${X?"nice-picklist__item--selected":""} ${y}`,role:"option","aria-selected":X,draggable:M,onDragStart:M?G=>_e(G,H):void 0,onDragOver:M?G=>te(G,H):void 0,onDrop:M?G=>we(G,H):void 0,onDragEnd:M?()=>d(null):void 0,onClick:()=>!q&&c(ee,U,H),onKeyDown:G=>{(G.key===" "||G.key==="Enter")&&(G.preventDefault(),q||c(ee,U,H))},children:[M&&e.jsx("span",{className:"nice-picklist__drag-handle","aria-hidden":"true",children:e.jsx(r.NiceIcon,{name:"grip",size:T})}),g?g(fe,ue):String(fe[s])]},H)})]},re.label||"__none__")),de.length===0&&e.jsx("div",{className:"nice-picklist__empty",children:l("controls.noItems","No items")})]})]})};return e.jsxs("div",{ref:k,id:Z,className:`nice-picklist nice-picklist--${se} ${q?"nice-picklist--disabled":""} ${oe||""}`,style:ce,...F,children:[ie(t,Y,A,C,f,B??l("picklist.source","Available"),"left",D),e.jsxs("div",{className:"nice-picklist__controls",children:[e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:q||Y.size===0,onClick:p,"aria-label":l("picklist.moveRight","Move right"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:T})}),z.moveAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:q||t.length===0,onClick:N,"aria-label":l("picklist.moveAllRight","Move all right"),children:e.jsx(r.NiceIcon,{name:"chevrons-right",size:T})}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:q||_.size===0,onClick:E,"aria-label":l("picklist.moveLeft","Move left"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:T})}),z.removeAll&&e.jsx("button",{type:"button",className:`nice-btn nice-btn--outline nice-btn--${se}`,disabled:q||i.length===0,onClick:m,"aria-label":l("picklist.moveAllLeft","Move all left"),children:e.jsx(r.NiceIcon,{name:"chevrons-left",size:T})})]}),ie(i,_,b,S,K,I??l("picklist.target","Selected"),"right",j)]})}),{displayName:"NicePickList"});function Tt(t){return t?.startsWith("datetime")?"datetime":t==="week"?"week":t?.startsWith("month")?"month":"date"}function qn(t){const i=new Date,o=`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`,a=Tt(t);return a==="datetime"?`${o}T00:00`:a==="month"?o.slice(0,7):o}function Ht(t,i){if(!t)return t;const o=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(o.getTime()))return t;o.setDate(o.getDate()+i);const a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-${String(o.getDate()).padStart(2,"0")}`;return t.length<=10?a.slice(0,t.length):a+t.slice(10)}function ft(...t){return t.filter(Boolean).sort().pop()}function Ft(t,i,o){if(!t)return"";const a=new Date(t.length<=10?`${t}T00:00`:t);if(Number.isNaN(a.getTime()))return t;const s=Tt(o);return s==="month"?a.toLocaleDateString(i,{year:"numeric",month:"2-digit"}):s==="datetime"?a.toLocaleString(i,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):a.toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"})}function Kt(t){let i=0;for(const o of t)i+=/[\p{L}\p{N}]/u.test(o)?1:.5;return i}function Ut(t){const i=/^(\d{4})-(\d{2})(?:-(\d{2}))?(?:T(\d{2}):(\d{2}))?$/.exec(t);if(!i)return!1;const[,o,a,s="01",g="00",x="00"]=i,$=new Date(Number(o),Number(a)-1,Number(s));return $.getMonth()===Number(a)-1&&$.getDate()===Number(s)&&Number(g)<24&&Number(x)<60}const Vn=({startDate:t,endDate:i,defaultStartDate:o,defaultEndDate:a,onStartChange:s,onEndChange:g,min:x,max:$,clearable:P,startPlaceholder:M,endPlaceholder:W,startLabel:J,endLabel:B,layout:I="horizontal",separator:q="–",gap:se=12,fullWidth:oe=!1,dateFormatPreset:ce,locale:Z,timeSelectorType:F,endCondition:k="greater-or-equal",startCondition:l="today-or-greater",singleField:T=!1,label:Y,error:A,helperText:_,required:b,disabled:C,size:f="md",id:S,className:K,style:w,accessMode:d,showKeyboardHints:D,labelPlacement:j,errorPlacement:h,labelWidth:c,controlWidth:p,loading:E,readOnly:N})=>{const m=r.useNiceAccessMode(d,S),R=r.useControlId(S),{t:z}=r.useNiceTranslation(),ie=m==="disabled"||m==="readOnly"||!!C,[v,ee]=r.useControllableState({value:t,defaultValue:o,fallbackValue:"",onChange:s,componentName:"NiceDateRangeBox"}),[U,me]=r.useControllableState({value:i,defaultValue:a,fallbackValue:"",onChange:g,componentName:"NiceDateRangeBox"}),pe=n.useMemo(()=>[{key:"Tab",description:z("shortcuts.switchField","Switch between start/end")},r.COMMON_SHORTCUTS.cancel],[z]),ye=n.useRef(null),ue=n.useRef(null),[he,de]=n.useState(!1),[ge,ae]=n.useState(null),[ve,_e]=n.useState(""),te=n.useContext(r.NiceThemeContext),we=te?.portalTarget??(typeof document<"u"?document.body:null),re=Z||Ue.getDefaultLocale(),fe=n.useMemo(()=>Ue.rangeMaskSpec(ce,re),[ce,re]),[H,X]=n.useState(null);n.useLayoutEffect(()=>{if(!he)return;const L=ye.current?.getBoundingClientRect();L&&(ae({left:L.left,top:L.bottom+6}),_e(te?.portalTarget?"":tt.scopeThemeClass(ye.current)))},[he,te?.portalTarget]),n.useEffect(()=>{if(!he)return;const L=Ce=>{const Pe=Ce.target;ye.current?.contains(Pe)||ue.current?.contains(Pe)||de(!1)},ke=()=>{const Ce=ye.current?.getBoundingClientRect();Ce&&ae({left:Ce.left,top:Ce.bottom+6})};return document.addEventListener("mousedown",L),window.addEventListener("scroll",ke,!0),window.addEventListener("resize",ke),()=>{document.removeEventListener("mousedown",L),window.removeEventListener("scroll",ke,!0),window.removeEventListener("resize",ke)}},[he]),r.useOverlayFocus(ue,{open:he,modal:!1,initialFocus:'.nice-calendar__grid [tabindex="0"]',onClose:()=>de(!1)});const O=qn(ce),y=l==="today-or-greater"?ft(x,O):l==="greater-than-today"?ft(x,Ht(O,1)):x,G=k==="greater-or-equal"?ft(x,v):k==="greater"?ft(x,v?Ht(v,1):void 0):x,ne=n.useMemo(()=>{if(A)return A;if(v&&U){if(k==="greater-or-equal"&&U<v)return z("daterange.endBeforeStart","End date must be on or after the start date");if(k==="greater"&&U<=v)return z("daterange.endAfterStart","End date must be after the start date")}if(v){if(l==="today-or-greater"&&v<O)return z("daterange.startInPast","Start date cannot be in the past");if(l==="greater-than-today"&&v<=O)return z("daterange.startAfterToday","Start date must be after today")}},[A,v,U,l,k,O,z]);if(m==="hidden")return null;const le=L=>{ee(L),L&&U&&L>U&&me(L)},be=I==="horizontal",xe=Tt(ce),Se=re,Te=typeof q=="string"&&q!==""?q:"–",Me=xe!=="week"&&ce!=="time",ze=Ue.dateMaskDigits.slots(fe),qe=L=>L?Me?Ue.dateMaskDigits.render(fe,Ue.dateMaskDigits.fromIso(fe,L)):Ft(L,Se,ce):"",Ve=qe(v),Ge=qe(U),We=Ve||Ge?`${Ve||"…"} ${Te} ${Ge||"…"}`:"",Ee=L=>{const ke=Ue.dateMaskDigits.render(fe,L.slice(0,ze));return L.length<ze?ke:`${ke} ${Te} ${Ue.dateMaskDigits.render(fe,L.slice(ze))}`},Je=`${fe.placeholder} ${Te} ${fe.placeholder}`,$e=(()=>{const L=Me?fe.placeholder:Ft("2026-12-30T22:58",Se,ce),ke=`${L} ${Te} ${L}`;return`${(Math.max(Kt(ke),Kt(We))+1.5).toFixed(1)}ch`})(),Ze=(L,ke)=>xe==="datetime"?ke&&ke.length>10?`${L}${ke.slice(10)}`:`${L}T00:00`:xe==="month"?L.slice(0,7):L,Le=({start:L,end:ke})=>{X(null),ee(L?Ze(L,v):""),me(ke?Ze(ke,U):""),L&&ke&&de(!1)},Ae=()=>{X(null),ee(""),me("")},Oe=L=>{const ke=H!==null?Ee(H):We;let Ce=L.replace(/\D/g,"").slice(0,ze*2);if(L.length<ke.length&&Ce===ke.replace(/\D/g,"")&&(Ce=Ce.slice(0,-1)),Ce.length===0){Ae();return}X(Ce);const Pe=Ce.length>=ze?Ue.dateMaskDigits.toIso(fe,Ce.slice(0,ze)):"";Pe&&Ut(Pe)&&Pe!==v&&ee(Pe);const He=Ce.length===ze*2?Ue.dateMaskDigits.toIso(fe,Ce.slice(ze)):"";He&&Ut(He)&&He!==U&&me(He)},at=()=>{H!==null&&(H.length<ze&&ee(""),H.length<ze*2&&me(""),X(null))},u=()=>{!ie&&!N&&de(L=>!L)},V=L=>L&&L.length>=10?L.slice(0,10):L||void 0;return e.jsxs("div",{className:`nice-field nice-field--${f} nice-daterange nice-daterange--${I} ${j==="left"?"nice-field--label-left":""} ${ne?"nice-field--error":""} ${E?"nice-field--loading":""} ${K||""}`,style:{...w,...c!=null&&{"--nice-field-label-width":typeof c=="number"?`${c}px`:c},...p!=null&&{"--nice-field-control-width":typeof p=="number"?`${p}px`:p}},"aria-busy":E||void 0,children:[Y&&e.jsxs("label",{className:"nice-field__label",htmlFor:R,children:[Y,b&&e.jsx("span",{className:"nice-field__required",children:"*"}),D&&e.jsx(r.NiceKeyboardHint,{shortcuts:pe,size:"sm"})]}),e.jsxs("div",{className:"nice-field__control",children:[T?e.jsxs("div",{ref:ye,className:`nice-input nice-input--date nice-input--${f} nice-daterange__single ${ne?"nice-input--error":""} ${ie?"nice-input--disabled":""} ${N?"nice-input--readonly":""}`,style:{position:"relative",width:oe?"100%":"fit-content"},children:[e.jsx("input",{id:R,className:"nice-input__native",type:"text",readOnly:!Me||N,value:H!==null?Ee(H):We,placeholder:M||(Me?Je:z("controls.startDate","Start date")),disabled:ie||E,autoComplete:"off",spellCheck:!1,inputMode:Me?"numeric":void 0,"aria-invalid":!!ne,"aria-label":Y?void 0:z("controls.startDate","Start date"),"aria-haspopup":"dialog","aria-expanded":he,onClick:Me?void 0:u,onChange:Me?L=>Oe(L.target.value):void 0,onBlur:Me?at:void 0,onKeyDown:L=>{const ke=!!L.nativeEvent.niceSource;(L.key==="Enter"||L.key===" "&&!Me||L.key==="ArrowDown"&&!ke)&&(L.preventDefault(),he||u())},style:{width:oe?"100%":$e,cursor:ie||N?void 0:Me?"text":"pointer"}}),P&&e.jsx("button",{type:"button",className:"nice-input__clear",onClick:Ae,disabled:!v&&!U||ie||N,"aria-label":z("controls.clear","Clear"),tabIndex:(v||U)&&!ie&&!N?0:-1,children:e.jsx(r.NiceIcon,{name:"close",size:14})}),e.jsx("button",{type:"button",className:"nice-input__picker-trigger",onClick:u,"aria-label":z("controls.openPicker","Open picker"),"aria-expanded":he,tabIndex:-1,disabled:ie||N,children:e.jsx(r.NiceIcon,{name:"calendar",size:16})})]}):e.jsxs("div",{className:"nice-daterange__row",style:{display:"flex",flexDirection:be?"row":"column",alignItems:be?j==="left"?"center":"flex-end":"stretch",gap:se,flexWrap:be?"nowrap":"wrap"},children:[e.jsx("div",{style:{flex:oe?"1 1 0":void 0,minWidth:0},children:e.jsx(Ue.NiceDateTimePicker,{id:R,dateFormatPreset:ce,displayLocale:Z,timeSelectorType:F,label:J,value:v,onChange:le,min:y,max:U||$,placeholder:M,disabled:ie,readOnly:N,size:f,clearable:P,labelPlacement:j,labelWidth:c})}),be&&q!==""&&q!=null&&e.jsx("span",{className:"nice-daterange__separator",style:{paddingBottom:8,color:"var(--nice-text-secondary, #666)"},"aria-hidden":"true",children:q}),e.jsx("div",{style:{flex:oe?"1 1 0":void 0,minWidth:0},children:e.jsx(Ue.NiceDateTimePicker,{dateFormatPreset:ce,displayLocale:Z,timeSelectorType:F,label:B,value:U,onChange:L=>me(L),min:G||v||x,max:$,placeholder:W,disabled:ie,readOnly:N,size:f,clearable:P,labelPlacement:j,labelWidth:c})})]}),T&&he&&ge&&we&&ot.createPortal(e.jsxs("div",{ref:ue,className:`nice-datetime-popup${ve?` ${ve}`:""}`,style:{position:"fixed",left:ge.left,top:ge.top,zIndex:1e3},role:"dialog","aria-label":z("controls.openPicker","Open picker"),children:[e.jsx("div",{className:"nice-datetime-popup__body",children:e.jsx("div",{className:"nice-datetime-popup__col nice-datetime-popup__col--date",children:e.jsx(Ue.NiceCalendar,{selectionMode:"range",rangeStart:V(v),rangeEnd:V(U),onRangeChange:Le,min:V(y),max:V($),size:f})})}),P&&e.jsx("div",{className:"nice-datetime-popup__footer",children:e.jsx("button",{type:"button",className:"nice-datetime-popup__btn",onClick:Ae,disabled:!v&&!U,children:z("controls.clear","Clear")})})]}),we),E&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),h==="right"&&ne&&e.jsx("div",{className:"nice-field__error",role:"alert",children:ne}),h==="right"&&!ne&&_&&e.jsx("div",{className:"nice-field__helper",children:_})]}),h!=="right"&&ne&&e.jsx("div",{className:"nice-field__error",children:ne}),h!=="right"&&!ne&&_&&e.jsx("div",{className:"nice-field__hint",children:_})]})};function Gn(t,i=30){switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-i,180+i];case"analogous":return[0,-i,i];case"analogous-complementary":return[0,-i,i,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270];case"shade-chain":return[];case"custom":return[0,60,200];default:return[0]}}function Yt(t,i={}){const o=i.size??16,a="currentColor",s="currentColor";if(i.rectangle||t==="shade-chain"||t==="monochromatic"){const J=Math.max(3,Math.min(7,i.count??5)),B=o*.1,I=o-B*2,q=Math.max(1.2,o/14),se=o/2,oe=Array.from({length:J},(ce,Z)=>{const F=B+I*Z/(J-1),k=.25+.75*Z/(J-1);return e.jsx("circle",{cx:F,cy:se,r:q,fill:s,opacity:k},Z)});return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("rect",{x:1,y:o/2-o/6,width:o-2,height:o/3,rx:o/6,fill:"none",stroke:a,strokeOpacity:.25}),oe]})}const x=i.angles??Gn(t),$=o/2,P=o/2,M=o/2-2,W=Math.max(1.4,o/9);return e.jsxs("svg",{width:o,height:o,viewBox:`0 0 ${o} ${o}`,"aria-hidden":!0,children:[e.jsx("circle",{cx:$,cy:P,r:M,fill:"none",stroke:a,strokeOpacity:.25}),x.map((J,B)=>{const I=(J-90)*Math.PI/180,q=$+M*Math.cos(I),se=P+M*Math.sin(I);return e.jsx("circle",{cx:q,cy:se,r:W,fill:s},B)})]})}function Xt(t,i,o){return Math.max(i,Math.min(o,t))}function dn({h:t,s:i,v:o}){t=(t%360+360)%360;const a=o*i,s=a*(1-Math.abs(t/60%2-1)),g=o-a;let x=0,$=0,P=0;return t<60?(x=a,$=s):t<120?(x=s,$=a):t<180?($=a,P=s):t<240?($=s,P=a):t<300?(x=s,P=a):(x=a,P=s),{r:Math.round((x+g)*255),g:Math.round(($+g)*255),b:Math.round((P+g)*255)}}function Rt({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),s=Math.min(t,i,o),g=a-s;let x=0;return g!==0&&(a===t?x=(i-o)/g%6:a===i?x=(o-t)/g+2:x=(t-i)/g+4,x=(x*60+360)%360),{h:x,s:a===0?0:g/a,v:a}}function mn({r:t,g:i,b:o}){t/=255,i/=255,o/=255;const a=Math.max(t,i,o),s=Math.min(t,i,o),g=(a+s)/2;if(a===s)return{h:0,s:0,l:g};const x=a-s,$=g>.5?x/(2-a-s):x/(a+s);let P=0;return a===t?P=((i-o)/x+(i<o?6:0))/6:a===i?P=((o-t)/x+2)/6:P=((t-i)/x+4)/6,{h:P*360,s:$,l:g}}function ut(t){const i=t.replace("#",""),o=i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i,a=parseInt(o,16);return{r:a>>16&255,g:a>>8&255,b:a&255}}function un({r:t,g:i,b:o}){return"#"+[t,i,o].map(a=>a.toString(16).padStart(2,"0")).join("")}function Be(t){return un(dn(t))}function Ye(t){return Rt(ut(t))}function pn(t,i){const o=[];for(let a=0;a<i;a++){const s=i<=1?.5:a/(i-1),g=Xt(t.s*(.3+s*.7),0,1),x=Xt(t.v*(1.2-s*.7),0,1);o.push(Be({h:t.h,s:g,v:x}))}return o}function _t(t,i){if(t==="custom"||t==="shade-chain")return[0];const o=i??30;switch(t){case"monochromatic":return[0];case"complementary":return[0,180];case"split-complementary":return[0,180-o,180+o];case"analogous":return[0,-o,o];case"analogous-complementary":return[0,-o,o,180];case"triadic":return[0,120,240];case"tetradic":return[0,60,180,240];case"square":return[0,90,180,270]}return[0]}function mt(t,i,o){return _t(i,o).map(a=>((t+a)%360+360)%360)}function qt(t,i,o=.12){const a=Math.max(2,i),s=(a-1)/2,g=[];for(let x=0;x<a;x++){const $=(x-s)*o,P=Math.max(.05,Math.min(.98,t.v+$)),M=Math.max(.05,Math.min(1,t.s-Math.abs($)*.25));g.push(Be({h:t.h,s:M,v:P}))}return g}function Vt({r:t,g:i,b:o}){const[a,s,g]=[t,i,o].map(x=>{const $=x/255;return $<=.03928?$/12.92:Math.pow(($+.055)/1.055,2.4)});return .2126*a+.7152*s+.0722*g}function xt(t,i){const o=Vt(ut(t)),a=Vt(ut(i)),s=Math.max(o,a),g=Math.min(o,a);return(s+.05)/(g+.05)}function bt(t){return t>=7?"AAA":t>=4.5?"AA":t>=3?"AA-lg":"Fail"}const hn={"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 jt(t,i){const o=hn[i];return t.map(a=>{const s=(o.sRange[0]+o.sRange[1])/2,g=(o.vRange[0]+o.vRange[1])/2;return Be({h:a,s,v:g})})}function Wn(){return Math.floor(Math.random()*360)}function gn(t,i,o){const a=Wn(),s=mt(a,t,o),g=[];for(let x=0;x<i;x++){const $=s[x%s.length],P=.55+Math.random()*.4,M=.5+Math.random()*.45;g.push(Be({h:$+(Math.random()-.5)*8,s:P,v:M}))}return g}const Jn=({hues:t,colors:i,baseHue:o,onBaseHueChange:a,mode:s,distance:g,disabled:x})=>{const{t:$}=r.useNiceTranslation(),P=240,M=P/2,W=P/2,J=110,B=55,I=l=>{if(x)return;const T=l.shiftKey?15:1,Y=l.key==="ArrowLeft"||l.key==="ArrowDown"?-T:l.key==="ArrowRight"||l.key==="ArrowUp"?T:l.key==="PageDown"?-15:l.key==="PageUp"?15:null;Y!==null?(l.preventDefault(),a(((o+Y)%360+360)%360)):(l.key==="Home"||l.key==="End")&&(l.preventDefault(),a(l.key==="Home"?0:359))},q=n.useRef(null),se=n.useCallback((l,T)=>{const Y=q.current;if(!Y)return;const A=Y.getBoundingClientRect(),_=(l-A.left)/A.width*P-M,b=(T-A.top)/A.height*P-W,C=(Math.atan2(b,_)*180/Math.PI+360)%360;a(Math.round(C))},[M,W,P,a]),oe=n.useCallback(l=>{if(x)return;l.preventDefault(),se(l.clientX,l.clientY);const T=A=>se(A.clientX,A.clientY),Y=()=>{document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",Y)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",Y)},[x,se]),ce=[];for(let l=0;l<360;l+=2){const T=(l-1)*Math.PI/180,Y=(l+1)*Math.PI/180,A=Be({h:l,s:1,v:1});ce.push(e.jsx("path",{d:`M${M+B*Math.cos(T)},${W+B*Math.sin(T)} L${M+J*Math.cos(T)},${W+J*Math.sin(T)} A${J},${J} 0 0,1 ${M+J*Math.cos(Y)},${W+J*Math.sin(Y)} L${M+B*Math.cos(Y)},${W+B*Math.sin(Y)} A${B},${B} 0 0,0 ${M+B*Math.cos(T)},${W+B*Math.sin(T)} Z`,fill:A},l))}const Z=`wheel-center-${s}`,F=t.map((l,T)=>{const Y=(J+B)/2,A=l*Math.PI/180;return e.jsx("circle",{cx:M+Y*Math.cos(A),cy:W+Y*Math.sin(A),r:T===0?8:6,fill:i?.[T]??Be({h:l,s:.85,v:.9}),stroke:T===0?"var(--nice-bg-primary, #fff)":"var(--nice-border-color, #ccc)",strokeWidth:T===0?3:2},T)});let k=null;if(s==="analogous"||s==="split-complementary"||s==="analogous-complementary"){const l=(J+B)/2,Y=_t(s,g).slice(1).map((A,_)=>{const b=(o+A)*Math.PI/180;return e.jsx("line",{x1:M,y1:W,x2:M+l*Math.cos(b),y2:W+l*Math.sin(b),stroke:"var(--nice-overlay-light-30, rgba(255, 255, 255, 0.3))",strokeWidth:1,strokeDasharray:"3,3"},`dline-${_}`)});k=e.jsx(e.Fragment,{children:Y})}return e.jsxs("svg",{ref:q,className:"nice-palette__wheel",viewBox:`0 0 ${P} ${P}`,width:P,height:P,onPointerDown:oe,onKeyDown:I,role:"slider",tabIndex:x?-1:0,"aria-label":$("colorPalette.baseHue","Base hue"),"aria-valuemin":0,"aria-valuemax":359,"aria-valuenow":Math.round(o),"aria-valuetext":`${Math.round(o)}°`,style:{cursor:x?"default":"crosshair",touchAction:"none"},children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:Z,children:[e.jsx("stop",{offset:"0%",stopColor:"var(--nice-bg, #fff)"}),e.jsx("stop",{offset:"100%",stopColor:"transparent"})]})}),ce,e.jsx("circle",{cx:M,cy:W,r:B-2,fill:Be({h:o,s:.6,v:.85})}),e.jsx("circle",{cx:M,cy:W,r:B-2,fill:`url(#${Z})`,opacity:.4}),k,F]})},Zn=({colors:t})=>{const{t:i}=r.useNiceTranslation();if(t.length<2)return null;const o=[];for(let a=0;a<t.length;a++){const s=xt(t[a],"var(--nice-bg-primary, #ffffff)"),g=xt(t[a],"var(--nice-text-primary, #000000)");o.push({a:t[a],b:"var(--nice-bg-primary, #ffffff)",ratio:s,level:bt(s)}),o.push({a:t[a],b:"var(--nice-text-primary, #000000)",ratio:g,level:bt(g)});for(let x=a+1;x<t.length;x++){const $=xt(t[a],t[x]);o.push({a:t[a],b:t[x],ratio:$,level:bt($)})}}return e.jsxs("div",{className:"nice-palette__contrast",children:[e.jsx("div",{className:"nice-palette__section-title",children:i("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx("div",{className:"nice-palette__contrast-grid",children:o.map((a,s)=>e.jsxs("div",{className:"nice-palette__contrast-pair",children:[e.jsxs("div",{className:"nice-palette__contrast-swatches",children:[e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.a}}),e.jsx("span",{className:"nice-palette__contrast-vs",children:i("colorPalette.vs","vs")}),e.jsx("span",{className:"nice-palette__contrast-dot",style:{background:a.b}})]}),e.jsxs("span",{className:"nice-palette__contrast-ratio",children:[a.ratio.toFixed(1),":1"]}),e.jsx("span",{className:`nice-palette__contrast-level nice-palette__contrast-level--${a.level.toLowerCase().replace("-","")}`,children:a.level})]},s))})]})},Qn=({hex:t})=>{const i=ut(t),o=mn(i),a=Rt(i);return e.jsxs("div",{className:"nice-palette__color-info",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"HEX"})," ",t.toUpperCase()]}),e.jsxs("div",{children:[e.jsx("strong",{children:"RGB"})," ",i.r,", ",i.g,", ",i.b]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSL"})," ",Math.round(o.h),"°, ",Math.round(o.s*100),"%,"," ",Math.round(o.l*100),"%"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"HSV"})," ",Math.round(a.h),"°, ",Math.round(a.s*100),"%,"," ",Math.round(a.v*100),"%"]})]})},ei={monochromatic:"Monochromatic",complementary:"Complementary","split-complementary":"Split-Complementary",analogous:"Analogous","analogous-complementary":"Analogous + Complementary",triadic:"Triadic",tetradic:"Tetradic (Rectangle)",square:"Square","shade-chain":"Shade chain",custom:"Custom"},ti={"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"},ni=["monochromatic","shade-chain","complementary","split-complementary","analogous","analogous-complementary","triadic","tetradic","square","custom"],fn=["lightest-pastel","bright-pastel","shiny","pastel","full","dark","deep","muted","earth"],yn="nice-palette-custom-schemes";function ii(){if(typeof window>"u")return[];try{const t=window.localStorage.getItem(yn);if(!t)return[];const i=JSON.parse(t);if(Array.isArray(i))return i}catch{}return[]}function oi(t){if(!(typeof window>"u"))try{window.localStorage.setItem(yn,JSON.stringify(t))}catch{}}const ai=Object.assign(n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:s,onChange:g,minColors:x=1,maxColors:$=8,harmonyMode:P,onHarmonyModeChange:M,distance:W,onDistanceChange:J,preset:B,onPresetChange:I,showWheel:q=!0,showContrast:se=!0,showInfo:oe=!0,showPresets:ce=!0,presets:Z=[],showVariations:F=!0,showRandom:k=!0,variationCount:l=5,label:T,labelPlacement:Y="top",disabled:A,readOnly:_,loading:b,error:C,colorCount:f,shadeStep:S,onShadeStepChange:K,customSchemes:w,onCustomSchemesChange:d,persistCustomSchemes:D=!0,"data-testid":j},h)=>{const c=r.useNiceAccessMode(a,t),p=c==="hidden";c==="disabled"&&(A=!0);const E=_||c==="readOnly",N=r.useControlId(t),{t:m}=r.useNiceTranslation(),R=tt.useNiceDialogs(),[z,ie]=n.useState("analogous-complementary"),[v,ee]=n.useState(30),[U,me]=n.useState(""),[pe,ye]=n.useState(0),[ue,he]=n.useState(.12),[de,ge]=n.useState(null),[ae,ve]=n.useState(()=>w??(D?ii():[])),[_e,te]=n.useState(null),[we,re]=n.useState(!1),[fe,H]=n.useState(null),[X,O]=n.useState(""),G=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),ne=n.useRef(null),le=n.useRef(null),be=P??z,xe=W??v,Se=B??U,Te=S??ue,Me=w??ae;n.useEffect(()=>{!w&&D&&oi(ae)},[ae,w,D]);const ze=n.useCallback(Q=>{ve(Q),d?.(Q)},[d]),qe=n.useCallback(Q=>{ie(Q),M?.(Q)},[M]),Ve=n.useCallback(Q=>{ee(Q),J?.(Q)},[J]),Ge=n.useCallback(Q=>{me(Q),Q&&I?.(Q)},[I]),We=n.useMemo(()=>["var(--nice-color-primary, #3b82f6)","var(--nice-color-error, #ef4444)","var(--nice-color-success, #22c55e)"],[]),Ee=s&&s.length>0?s:We,Je=Ee[0],$e=n.useMemo(()=>Ye(Je),[Je]),Ze=n.useMemo(()=>mt($e.h,be,xe),[$e.h,be,xe]),Le=n.useCallback((Q,je,Ne,Re,Xe)=>{const ht=f??Xe??de??Ee.length,nt=ht!==void 0?Math.max(x,Math.min($,ht)):void 0;if(je==="shade-chain"){const Ke=nt??Math.max(x,5),Qe=qt({h:Q,s:$e.s||.7,v:$e.v||.6},Ke,Te);g?.(Qe);return}let it;const rt=je==="custom"&&_e?Me.find(Ke=>Ke.id===_e):null;rt&&rt.angles.length>0?it=rt.angles.map(Ke=>((Q+Ke)%360+360)%360):it=mt(Q,je,Ne);let De;if(Re&&hn[Re]?De=jt(it,Re):De=it.map(Ke=>Be({h:Ke,s:$e.s||.7,v:$e.v||.85})),rt?.lightnessOffsets?.length&&(De=De.map((Ke,Qe)=>{const Lt=rt.lightnessOffsets?.[Qe];if(Lt==null)return Ke;const Nt=Ye(Ke);return Be({h:Nt.h,s:Nt.s,v:Math.max(.05,Math.min(.98,Nt.v+Lt))})})),nt!==void 0){for(;De.length<nt;){const Ke=De[De.length-1]||"#888888",Qe=Ye(Ke);De.push(Be({h:(Qe.h+18)%360,s:Qe.s,v:Qe.v}))}De=De.slice(0,nt)}else{for(;De.length<x;)De.push(De[De.length-1]||"var(--nice-text-secondary, #888888)");De.length>$&&(De=De.slice(0,$))}g?.(De)},[$e.s,$e.v,x,$,g,f,de,Ee.length,Te,_e,Me]),Ae=n.useCallback(Q=>{if(!A){if(be==="custom"){const je=Be({h:Q,s:$e.s||.7,v:$e.v||.85}),Ne=[...Ee];Ne[pe]=je,g?.(Ne);return}Le(Q,be,xe,Se)}},[A,be,xe,Se,Le,$e.s,$e.v,Ee,pe,g]),Oe=n.useCallback(Q=>{if(A||(qe(Q),Q==="custom"))return;const je=_t(Q).length,Ne=je<=1;if(f==null&&!Ne){const Re=Math.max(x,Math.min($,je));ge(Re),Le($e.h,Q,xe,Se,Re)}else Le($e.h,Q,xe,Se)},[A,$e.h,xe,Se,qe,Le,f,x,$]),at=n.useCallback(Q=>{A||(Ve(Q),Le($e.h,be,Q,Se))},[A,$e.h,be,Se,Ve,Le]),u=n.useCallback(Q=>{if(A)return;Ge(Q);const je=mt($e.h,be,xe),Ne=jt(je,Q);g?.(Ne.slice(0,$))},[A,$e.h,be,xe,$,Ge,g]),V=n.useCallback((Q,je)=>{if(A)return;const Ne=[...Ee];Ne[Q]=je,g?.(Ne)},[A,Ee,g]),L=n.useCallback(()=>{if(A||Ee.length>=$)return;const Q=Ye(Ee[Ee.length-1]),je=Be({h:(Q.h+30)%360,s:Q.s,v:Q.v});g?.([...Ee,je])},[A,Ee,$,g]),ke=n.useCallback(Q=>{if(A||Ee.length<=x)return;const je=Ee.filter((Ne,Re)=>Re!==Q);g?.(je),pe>=je.length&&ye(Math.max(0,je.length-1))},[A,Ee,x,g,pe]),Ce=n.useCallback(()=>{if(A)return;const Q=Math.max(x,Math.min($,_t(be).length)),je=gn(be,Q,xe);g?.(je)},[A,x,$,be,xe,g]),Pe=n.useMemo(()=>{if(!F)return[];const Q=Ee[pe]||Ee[0];return pn(Ye(Q),l)},[F,Ee,pe,l]),He=Ee[pe]||Ee[0],wt=n.useMemo(()=>{const Q=Ye(He);return Be({h:(Q.h+180)%360,s:Q.s,v:Q.v})},[He]);n.useLayoutEffect(()=>{if(!we||!ne.current)return;O(tt.scopeThemeClass(ne.current));const Q=()=>{const je=ne.current?.getBoundingClientRect();if(!je)return;const Ne=600;let Re=je.left;Re+Ne>window.innerWidth-8&&(Re=Math.max(8,window.innerWidth-Ne-8));let Xe=je.bottom+6;Xe>window.innerHeight*.5&&(Xe=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,540)-8)),H({left:Re,top:Xe})};return Q(),window.addEventListener("scroll",Q,!0),window.addEventListener("resize",Q),()=>{window.removeEventListener("scroll",Q,!0),window.removeEventListener("resize",Q)}},[we]),n.useEffect(()=>{if(!we)return;const Q=je=>{const Ne=je.target;ne.current?.contains(Ne)||le.current?.contains(Ne)||(Ne instanceof Element?Ne:Ne?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"], [aria-modal="true"]')||re(!1)};return document.addEventListener("mousedown",Q),()=>{document.removeEventListener("mousedown",Q)}},[we]),r.useOverlayFocus(le,{open:we,modal:!1,onClose:()=>re(!1)});const Dt=n.useRef(null);if(r.useRovingFocus(Dt,{orientation:"horizontal",itemSelector:".nice-palette__variation-chip"}),p)return null;const zt=Z.length>0?Z:fn,$n=e.jsxs("div",{className:"nice-palette__tab",children:[e.jsxs("div",{className:"nice-palette__modes",style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx(Fe.NiceSelect,{label:m("colorPalette.harmony","Harmony"),labelPlacement:"left",size:"sm",disabled:A,value:be==="custom"&&_e?`custom:${_e}`:be,onChange:Q=>{const je=Array.isArray(Q)?Q[0]:Q;if(typeof je=="string")if(je.startsWith("custom:")){const Ne=je.slice(7);te(Ne),Oe("custom")}else te(null),Oe(je)},options:[...ni.map(Q=>({value:Q,label:ei[Q]})),...Me.map(Q=>({value:`custom:${Q.id}`,label:Q.name}))],renderOption:(Q,je)=>{const Ne=String(Q.value),Re=Ne.startsWith("custom:"),Xe=Re?Me.find(it=>it.id===Ne.slice(7)):null,ht=Xe?Xe.angles:void 0,nt=Re?"custom":Ne;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:Yt(nt,{angles:ht,size:16,count:f})}),e.jsx("span",{style:{fontWeight:je?600:400},children:Q.label})]})}}),be==="shade-chain"&&e.jsx(Fe.NiceNumberInput,{label:m("colorPalette.step","Step"),labelPlacement:"left",size:"sm",min:.02,max:.5,step:.02,precision:2,value:Te,onChange:Q=>{const je=typeof Q=="number"?Q:Number(Q);Number.isNaN(je)||(he(je),K?.(je),Le($e.h,be,xe,Se))},showStepper:!0,disabled:A}),e.jsx(Fe.NiceNumberInput,{label:m("colorPalette.colors","Colors"),labelPlacement:"left",size:"sm",min:Math.max(2,x),max:Math.min(12,$),step:1,precision:0,value:f??de??Ee.length,onChange:Q=>{const je=typeof Q=="number"?Q:Number(Q);if(!Number.isFinite(je))return;const Ne=Math.max(Math.max(2,x),Math.min(Math.min(12,$),Math.round(je)));ge(Ne),be==="shade-chain"?g?.(qt({h:$e.h,s:$e.s||.7,v:$e.v||.6},Ne,Te)):setTimeout(()=>Le($e.h,be,xe,Se),0)},showStepper:!0,disabled:A})]}),e.jsx("div",{className:"nice-palette__main",children:e.jsxs("div",{className:"nice-palette__strips",children:[e.jsxs("div",{className:"nice-palette__swatches",children:[Ee.map((Q,je)=>e.jsxs("div",{role:"presentation",className:`nice-palette__swatch-wrapper ${pe===je?"nice-palette__swatch-wrapper--selected":""}`,onClick:()=>ye(je),onFocus:()=>ye(je),children:[e.jsx("span",{className:"nice-palette__swatch",style:{background:Q}}),e.jsx("input",{type:"text",className:"nice-palette__hex-input",value:Q.toUpperCase(),maxLength:7,disabled:A,onClick:Ne=>Ne.stopPropagation(),onChange:Ne=>V(je,Ne.target.value),"aria-label":m("colorPalette.colorN","Color {n}").replace("{n}",String(je+1))}),Ee.length>x&&e.jsx("button",{type:"button",className:"nice-palette__swatch-remove",onClick:Ne=>{Ne.stopPropagation(),ke(je)},disabled:A,"aria-label":m("colorPalette.removeColor","Remove color"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},je)),Ee.length<$&&e.jsxs("button",{type:"button",className:"nice-palette__add-btn",onClick:L,disabled:A,title:m("colorPalette.addColor","Add color"),children:[e.jsx(r.NiceIcon,{name:"plus",size:14}),e.jsx("span",{children:m("colorPalette.add","Add")})]})]}),e.jsxs("div",{className:"nice-palette__complementary",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.complementary","Complementary")}),e.jsx("div",{className:"nice-palette__swatch nice-palette__swatch--sm",style:{background:wt},title:wt.toUpperCase()}),e.jsx("span",{className:"nice-palette__hex-label",children:wt.toUpperCase()})]}),k&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-palette__random-btn",onClick:Ce,disabled:A,title:m("colorPalette.randomPalette","Random palette"),"aria-label":m("colorPalette.randomPalette","Random palette"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",m("colorPalette.randomPalette2","Random Palette")]})]})})]}),In=e.jsx("div",{className:"nice-palette__tab",children:Pe.length>0?e.jsxs("div",{className:"nice-palette__variations",children:[e.jsx("span",{className:"nice-palette__section-tag",children:m("colorPalette.tintsShades","Tints & Shades")}),e.jsx("div",{ref:Dt,className:"nice-palette__variation-strip",role:"group","aria-label":m("colorPalette.tintsShades","Tints & Shades"),children:Pe.map((Q,je)=>e.jsx("div",{className:"nice-palette__variation-chip",style:{background:Q},title:Q.toUpperCase(),onClick:()=>{A||V(pe,Q)},onKeyDown:Ne=>{!A&&(Ne.key==="Enter"||Ne.key===" ")&&(Ne.preventDefault(),V(pe,Q))},role:"button","aria-label":Q.toUpperCase()},je))})]}):e.jsx("div",{className:"nice-palette__empty",children:m("colorPalette.noVariationsAvailable","No variations available.")})}),Mn=e.jsx("div",{className:"nice-palette__tab",children:e.jsx("div",{className:"nice-palette__preset-grid",children:zt.map(Q=>{const je=jt(Ze,Q);return e.jsxs("button",{type:"button",className:`nice-palette__preset-card ${Se===Q?"nice-palette__preset-card--active":""}`,onClick:()=>u(Q),disabled:A,children:[e.jsx("div",{className:"nice-palette__preset-strip",children:je.map((Ne,Re)=>e.jsx("span",{className:"nice-palette__preset-dot",style:{background:Ne}},Re))}),e.jsx("span",{className:"nice-palette__preset-label",children:ti[Q]})]},Q)})})}),Tn=e.jsxs("div",{className:"nice-palette__tab",children:[oe&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:m("colorPalette.selectedColorInfo","Selected Color Info")}),e.jsx(Qn,{hex:He})]}),se&&e.jsxs("div",{className:"nice-palette__info-panel",children:[e.jsx("div",{className:"nice-palette__section-title",children:m("colorPalette.contrastAnalysisWcag21","Contrast Analysis (WCAG 2.1)")}),e.jsx(Zn,{colors:Ee})]})]}),Rn=e.jsx("div",{className:"nice-palette__tab nice-palette__custom-schemes",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[Me.length===0&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted)"},children:m("colorPalette.schemes.empty","Save the current palette as a reusable scheme.")}),Me.map(Q=>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:Yt("custom",{angles:Q.angles,size:16})}),e.jsx("span",{style:{flex:1},children:Q.name}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>{te(Q.id),Oe("custom")},disabled:A,children:m("colorPalette.use","Use")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--xs",onClick:()=>ze(Me.filter(je=>je.id!==Q.id)),disabled:A,"aria-label":m("colorPalette.delete","Delete {name}").replace("{name}",String(Q.name)),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},Q.id)),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A,onClick:()=>{const Q=Ye(Ee[0]).h,je=Ee.map(Ne=>(Ye(Ne).h-Q+540)%360-180);R.prompt({title:m("colorPalette.schemeNamePrompt","Scheme name"),defaultValue:`Scheme ${Me.length+1}`}).then(Ne=>{if(!Ne)return;const Re={id:`cs-${Date.now()}`,name:Ne,angles:je};ze([...Me,Re])})},children:m("colorPalette.saveCurrentAsScheme","+ Save current as scheme")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A||Me.length===0,onClick:()=>{typeof navigator>"u"||navigator.clipboard?.writeText(JSON.stringify(Me,null,2))},children:m("colorPalette.exportJson","Export JSON")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",disabled:A,onClick:()=>{R.prompt({title:m("colorPalette.pasteSchemesPrompt","Paste the schemes JSON")}).then(Q=>{if(Q)try{const je=JSON.parse(Q);Array.isArray(je)&&ze(je)}catch{}})},children:m("colorPalette.importJson","Import JSON")})]})]})}),st=[{id:"colors",label:m("colorPalette.colors","Colors"),content:$n}];ce&&zt.length>0&&st.push({id:"presets",label:m("colorPalette.presets","Presets"),content:Mn}),F&&st.push({id:"variations",label:m("colorPalette.variations","Variations"),content:In}),(oe||se)&&st.push({id:"info",label:m("colorPalette.info","Info"),content:Tn}),st.push({id:"schemes",label:m("colorPalette.schemes","Schemes"),content:Rn});const An=e.jsxs("div",{className:"nice-palette__popup-header",children:[q&&e.jsxs("div",{className:"nice-palette__wheel-container",children:[e.jsx(Jn,{hues:Ze,colors:Ee,baseHue:$e.h,onBaseHueChange:Ae,mode:be,distance:xe,disabled:A}),(be==="analogous"||be==="split-complementary"||be==="analogous-complementary")&&e.jsxs("div",{className:"nice-palette__distance",children:[e.jsx("label",{children:m("colorPalette.distance","Distance: {dist}°").replace("{dist}",String(xe))}),e.jsx("input",{type:"range",min:10,max:90,value:xe,onChange:Q=>at(Number(Q.target.value)),disabled:A,className:"nice-palette__distance-slider","aria-label":m("colorPalette.distanceLabel","Distance")})]})]}),e.jsx("button",{type:"button",className:"nice-palette__confirm",onClick:()=>re(!1),"aria-label":m("controls.confirm","Confirm"),title:m("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),Dn=e.jsxs("div",{className:"nice-palette nice-palette--studio",children:[An,e.jsx(pt.NiceTabs,{tabs:st,variant:"enclosed",size:"sm"})]});return e.jsxs("div",{ref:h,id:N,className:`nice-field nice-palette-field ${A?"nice-palette--disabled":""} ${Y==="left"?"nice-field--label-left":""} ${b?"nice-field--loading":""} ${C?"nice-field--error":""} ${i||""}`,style:o,"data-testid":j,children:[R.element,T&&e.jsx("label",{htmlFor:N,className:"nice-field__label",children:T}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("div",{ref:ne,className:"nice-palette__field-swatches",role:"button",tabIndex:A||E?-1:0,"aria-haspopup":"dialog","aria-expanded":we,"aria-readonly":E||void 0,"aria-label":m("colorPalette.openStudio","Open palette studio"),onClick:()=>{!A&&!E&&re(Q=>!Q)},onKeyDown:Q=>{!A&&!E&&(Q.key==="Enter"||Q.key===" ")&&(Q.preventDefault(),re(je=>!je))},children:Ee.map((Q,je)=>e.jsx("span",{role:"presentation",className:"nice-palette__field-swatch",style:{background:Q},title:Q.toUpperCase(),onClick:Ne=>{Ne.stopPropagation(),!A&&!E&&(ye(je),re(!0))}},je))}),b&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),we&&fe&&G&&ot.createPortal(e.jsx("div",{ref:le,className:`nice-palette__popup${X?` ${X}`:""}`,"data-theme":X==="nice-dark"?"dark":X==="nice-light"?"light":void 0,role:"dialog","aria-label":m("colorPalette.studio","Palette studio"),style:{position:"fixed",left:fe.left,top:fe.top,zIndex:1e3},children:Dn}),G)]}),typeof C=="string"&&C&&e.jsx("div",{className:"nice-field__error",role:"alert",children:C})]})}),{displayName:"NiceColorPalette"});function It(){return{type:"linear",angle:90,stops:[{color:"var(--nice-primary, #3b82f6)",position:0},{color:"var(--nice-accent, #8b5cf6)",position:100}]}}function Mt(t){const i=t.stops.slice().sort((a,s)=>a.position-s.position).map(a=>`${a.color} ${a.position}%`).join(", "),o=t.repeating?"repeating-":"";switch(t.type){case"linear":return`${o}linear-gradient(${t.angle}deg, ${i})`;case"radial":{const a=t.shape||"ellipse",s=t.size||"farthest-corner",g=t.positionX??50,x=t.positionY??50;return`${o}radial-gradient(${a} ${s} at ${g}% ${x}%, ${i})`}case"conic":{const a=t.angle??0,s=t.positionX??50,g=t.positionY??50;return`${o}conic-gradient(from ${a}deg at ${s}% ${g}%, ${i})`}}}function xn(t){const i=t.trim(),o=i.startsWith("repeating-");if(i.includes("linear-gradient")){const a=i.match(/linear-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(M=>M.trim());let g=90,x=0;const $=s[0].match(/^(\d+)deg$/);$&&(g=parseInt($[1]),x=1);const P=Ct(s.slice(x));return{type:"linear",angle:g,repeating:o,stops:P}}if(i.includes("radial-gradient")){const a=i.match(/radial-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(x=>x.trim()),g=Ct(s.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"radial",angle:0,repeating:o,stops:g.length>=2?g:It().stops}}if(i.includes("conic-gradient")){const a=i.match(/conic-gradient\((.+)\)/)?.[1];if(!a)return null;const s=a.split(",").map(x=>x.trim()),g=Ct(s.filter(x=>x.includes("#")||x.includes("rgb")));return{type:"conic",angle:0,repeating:o,stops:g.length>=2?g:It().stops}}return null}function Ct(t){return t.map((i,o,a)=>{const s=i.match(/^(#[0-9a-fA-F]{3,8}|rgba?\([^)]+\))\s*(\d+%?)?$/);if(s){const g=s[2]?parseFloat(s[2]):o/Math.max(1,a.length-1)*100;return{color:s[1],position:g}}return{color:i,position:o/Math.max(1,a.length-1)*100}})}function si(){return"#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0")}function ri(t=2){const i=["linear","radial","conic"],o=i[Math.floor(Math.random()*i.length)],a=[];for(let s=0;s<t;s++)a.push({color:si(),position:Math.round(s/(t-1)*100)});return{type:o,angle:Math.floor(Math.random()*360),stops:a,shape:o==="radial"?Math.random()>.5?"circle":"ellipse":void 0,positionX:o!=="linear"?Math.round(Math.random()*100):void 0,positionY:o!=="linear"?Math.round(Math.random()*100):void 0}}const bn=[{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}}],ci=Object.assign(n.forwardRef(({id:t,className:i,style:o,accessMode:a,value:s,onChange:g,showCssOutput:x=!0,showPresets:$=!0,showEditor:P=!0,showRandom:M=!0,maxStops:W=10,label:J,labelPlacement:B="top",disabled:I,readOnly:q,loading:se,error:oe,errorPlacement:ce="bottom",width:Z,"data-testid":F},k)=>{const l=r.useNiceAccessMode(a,t),T=l==="hidden";l==="disabled"&&(I=!0);const Y=q||l==="readOnly",A=r.useControlId(t),{t:_}=r.useNiceTranslation(),b=s??It(),C=n.useMemo(()=>Mt(b),[b]),[f,S]=n.useState(0),[K,w]=n.useState(""),d=n.useRef(null),[D,j]=n.useState(!1),[h,c]=n.useState(null),[p,E]=n.useState(""),m=n.useContext(r.NiceThemeContext)?.portalTarget??(typeof document<"u"?document.body:null),R=n.useRef(null),z=n.useRef(null),ie=typeof Z=="number"?Z:340;n.useLayoutEffect(()=>{if(!D||!R.current)return;E(tt.scopeThemeClass(R.current));const y=()=>{const G=R.current?.getBoundingClientRect();if(!G)return;let ne=G.left;ne+ie>window.innerWidth-8&&(ne=Math.max(8,window.innerWidth-ie-8));let le=G.bottom+6;le>window.innerHeight*.5&&(le=Math.max(8,window.innerHeight-Math.min(window.innerHeight-16,520)-8)),c({left:ne,top:le})};return y(),window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[D,ie]),n.useEffect(()=>{if(!D)return;const y=G=>{const ne=G.target;R.current?.contains(ne)||z.current?.contains(ne)||(ne instanceof Element?ne:ne?.parentElement??null)?.closest('.nice-select__dropdown, [role="listbox"], [role="option"]')||j(!1)};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[D]),r.useOverlayFocus(z,{open:D,modal:!1,onClose:()=>j(!1)});const v=n.useCallback(y=>{g?.(y)},[g]),ee=n.useCallback(y=>{I||v({...b,type:y})},[I,b,v]),U=n.useCallback(y=>{I||v({...b,angle:y})},[I,b,v]),me=n.useCallback(y=>{I||v({...b,repeating:y})},[I,b,v]),pe=n.useCallback(y=>{I||v({...b,shape:y})},[I,b,v]),ye=n.useCallback((y,G)=>{if(I)return;const ne=b.stops.map((le,be)=>be===y?{...le,...G}:le);v({...b,stops:ne})},[I,b,v]),ue=n.useRef(!1),he=n.useCallback((y,G)=>{if(I||!d.current)return;y.stopPropagation(),y.preventDefault(),S(G),ue.current=!1;const ne=be=>{if(!d.current)return;ue.current=!0;const xe=d.current.getBoundingClientRect(),Se=Math.round(Math.max(0,Math.min(100,(be.clientX-xe.left)/xe.width*100)));ye(G,{position:Se})},le=()=>{document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",le),document.removeEventListener("pointercancel",le)};document.addEventListener("pointermove",ne),document.addEventListener("pointerup",le),document.addEventListener("pointercancel",le)},[I,ye]),de=n.useCallback(()=>{if(I||b.stops.length>=W)return;const y=b.stops.slice().sort((xe,Se)=>xe.position-Se.position);let G=0,ne=y[0];for(let xe=0;xe<y.length-1;xe++){const Se=y[xe+1].position-y[xe].position;Se>G&&(G=Se,ne=y[xe])}const le=Math.round(ne.position+G/2),be="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0");v({...b,stops:[...b.stops,{color:be,position:le}]})},[I,b,W,v]),ge=n.useCallback(y=>{if(I||b.stops.length<=2)return;const G=b.stops.filter((ne,le)=>le!==y);v({...b,stops:G}),f>=G.length&&S(G.length-1)},[I,b,f,v]),ae=(y,G)=>{const ne=b.stops[G];if(I||!ne)return;const le=y.shiftKey?10:1,be=y.key==="ArrowLeft"||y.key==="ArrowDown"?ne.position-le:y.key==="ArrowRight"||y.key==="ArrowUp"?ne.position+le:y.key==="PageDown"?ne.position-10:y.key==="PageUp"?ne.position+10:y.key==="Home"?0:y.key==="End"?100:null;be!==null?(y.preventDefault(),ye(G,{position:Math.max(0,Math.min(100,be))})):(y.key==="Delete"||y.key==="Backspace")&&b.stops.length>2&&(y.preventDefault(),ge(G))},ve=n.useCallback(()=>{if(I)return;const y=2+Math.floor(Math.random()*3);v(ri(y))},[I,v]),_e=n.useCallback(()=>{if(I||!K.trim())return;const y=xn(K);y&&v(y)},[I,K,v]),te=n.useCallback(y=>{if(I||!d.current||b.stops.length>=W)return;const G=y.target;if(ue.current||G.closest(".nice-gradient__stop-marker")){ue.current=!1;return}const ne=d.current.getBoundingClientRect(),le=Math.round((y.clientX-ne.left)/ne.width*100),be="#"+Math.floor(Math.random()*16777215).toString(16).padStart(6,"0"),xe=[...b.stops,{color:be,position:le}];v({...b,stops:xe}),S(xe.length-1)},[I,b,W,v]),we=n.useMemo(()=>b.stops.slice().sort((y,G)=>y.position-G.position),[b.stops]),re=n.useMemo(()=>`linear-gradient(90deg, ${we.map(y=>`${y.color} ${y.position}%`).join(", ")})`,[we]);if(T)return null;const fe=e.jsxs("div",{className:"nice-gradient__tab",children:[P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-gradient__type-row",children:[["linear","radial","conic"].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__type-btn ${b.type===y?"nice-gradient__type-btn--active":""}`,onClick:()=>ee(y),disabled:I,"aria-pressed":b.type===y,children:y.charAt(0).toUpperCase()+y.slice(1)},y)),e.jsxs("label",{className:"nice-gradient__repeat-label",children:[e.jsx("input",{type:"checkbox",checked:b.repeating??!1,onChange:y=>me(y.target.checked),disabled:I}),_("controls.repeating","Repeating")]})]}),e.jsxs("div",{className:"nice-gradient__controls",children:[b.type==="linear"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.angle","Angle: {angle}°").replace("{angle}",String(b.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:b.angle,onChange:y=>U(Number(y.target.value)),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.angle","Angle")}),e.jsx("div",{className:"nice-gradient__angle-presets",children:[0,45,90,135,180,225,270,315].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__angle-btn ${b.angle===y?"nice-gradient__angle-btn--active":""}`,onClick:()=>U(y),disabled:I,title:`${y}°`,"aria-label":`${y}°`,"aria-pressed":b.angle===y,children:e.jsx("span",{style:{transform:`rotate(${y}deg)`,display:"inline-flex"},children:e.jsx(r.NiceIcon,{name:"arrow-right",size:14})})},y))})]}),b.type==="radial"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.shape","Shape:")}),e.jsx("div",{className:"nice-gradient__shape-btns",children:["circle","ellipse"].map(y=>e.jsx("button",{type:"button",className:`nice-gradient__shape-btn ${(b.shape||"ellipse")===y?"nice-gradient__shape-btn--active":""}`,onClick:()=>pe(y),disabled:I,"aria-pressed":(b.shape||"ellipse")===y,children:y},y))})]}),(b.type==="radial"||b.type==="conic")&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.center","Center: {positionX}%, {positionY}%").replace("{positionX}",String(b.positionX??50)).replace("{positionY}",String(b.positionY??50))}),e.jsxs("div",{className:"nice-gradient__center-inputs",children:[e.jsx("input",{type:"range",min:0,max:100,value:b.positionX??50,onChange:y=>v({...b,positionX:Number(y.target.value)}),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.centerX","Horizontal center")}),e.jsx("input",{type:"range",min:0,max:100,value:b.positionY??50,onChange:y=>v({...b,positionY:Number(y.target.value)}),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.centerY","Vertical center")})]})]}),b.type==="conic"&&e.jsxs("div",{className:"nice-gradient__control-group",children:[e.jsx("label",{children:_("controls.startAngle","Start angle: {angle}°").replace("{angle}",String(b.angle))}),e.jsx("input",{type:"range",min:0,max:360,value:b.angle,onChange:y=>U(Number(y.target.value)),disabled:I,className:"nice-gradient__slider","aria-label":_("gradient.startAngle","Start angle")})]})]}),e.jsxs("div",{className:"nice-gradient__bar-container",children:[e.jsx("div",{role:"presentation",ref:d,className:"nice-gradient__bar",style:{background:re},onClick:te,children:b.stops.map((y,G)=>e.jsx("div",{className:`nice-gradient__stop-marker ${f===G?"nice-gradient__stop-marker--active":""}`,style:{left:`${y.position}%`},onPointerDown:ne=>he(ne,G),onClick:ne=>{ne.stopPropagation(),S(G),ue.current=!1},onFocus:()=>S(G),onKeyDown:ne=>ae(ne,G),role:"slider",tabIndex:I?-1:0,"aria-label":_("gradient.stop","Stop {n}").replace("{n}",String(G+1)),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":y.position,"aria-valuetext":`${y.color} ${y.position}%`,title:`${y.color} @ ${y.position}%`,children:e.jsx("div",{className:"nice-gradient__stop-dot",style:{background:y.color}})},G))}),e.jsx("button",{type:"button",className:"nice-gradient__add-stop",onClick:de,disabled:I||b.stops.length>=W,title:_("controls.addStop","Add stop"),"aria-label":_("controls.addStop","Add stop"),children:e.jsx(r.NiceIcon,{name:"plus",size:14})})]}),e.jsx("div",{className:"nice-gradient__stop-editor",children:e.jsx("div",{className:"nice-gradient__stop-list",children:we.map((y,G)=>{const ne=b.stops.indexOf(y);return e.jsxs("div",{role:"presentation",className:`nice-gradient__stop-row ${f===ne?"nice-gradient__stop-row--active":""}`,onClick:()=>S(ne),onFocus:()=>S(ne),children:[e.jsx("input",{type:"color",value:y.color,onChange:le=>ye(ne,{color:le.target.value}),disabled:I,className:"nice-gradient__stop-color","aria-label":_("gradient.stopColor","Stop color")}),e.jsx("input",{type:"text",value:y.color.toUpperCase(),maxLength:7,onChange:le=>ye(ne,{color:le.target.value}),disabled:I,className:"nice-gradient__stop-hex","aria-label":_("gradient.stopHex","Stop color (hex)")}),e.jsx("input",{type:"number",min:0,max:100,value:y.position,onChange:le=>ye(ne,{position:Number(le.target.value)}),disabled:I,className:"nice-gradient__stop-pos","aria-label":_("gradient.stopPosition","Stop position")}),e.jsx("span",{className:"nice-gradient__stop-pct",children:"%"}),b.stops.length>2&&e.jsx("button",{type:"button",className:"nice-gradient__stop-del",onClick:()=>ge(ne),disabled:I,"aria-label":_("controls.removeStop","Remove stop"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},ne)})})})]}),M&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm nice-gradient__random-btn",onClick:ve,disabled:I,title:_("controls.randomGradient","Random gradient"),"aria-label":_("controls.randomGradient","Random gradient"),children:[e.jsx(r.NiceIcon,{name:"shuffle",size:14})," ",_("controls.randomGradient2","Random Gradient")]})]}),H=e.jsx("div",{className:"nice-gradient__tab",children:e.jsx("div",{className:"nice-gradient__preset-grid",children:bn.map((y,G)=>e.jsxs("button",{type:"button",className:"nice-gradient__preset-card",onClick:()=>{I||v(y.value)},disabled:I,title:y.name,children:[e.jsx("div",{className:"nice-gradient__preset-preview",style:{background:Mt(y.value)}}),e.jsx("span",{className:"nice-gradient__preset-name",children:y.name})]},G))})}),X=e.jsxs("div",{className:"nice-gradient__tab",children:[e.jsxs("div",{className:"nice-gradient__css-output",children:[e.jsx("code",{children:`background: ${C};`}),e.jsx("button",{type:"button",className:"nice-gradient__copy-btn",onClick:()=>navigator.clipboard?.writeText(`background: ${C};`),title:_("controls.copyCss","Copy CSS"),"aria-label":_("controls.copyCss","Copy CSS"),children:e.jsx(r.NiceIcon,{name:"clipboard",size:16})})]}),e.jsxs("div",{className:"nice-gradient__css-import",children:[e.jsx("input",{type:"text",className:"nice-gradient__css-input",placeholder:_("controls.pasteCssGradientToImport","Paste CSS gradient to import..."),value:K,onChange:y=>w(y.target.value),disabled:I,"aria-label":_("gradient.importCss","CSS gradient to import")}),e.jsx("button",{type:"button",className:"nice-btn nice-btn--outline nice-btn--sm",onClick:_e,disabled:I,children:_("controls.import","Import")})]})]}),O=[{id:"editor",label:_("controls.editor","Editor"),content:fe}];return $&&O.push({id:"presets",label:_("controls.presets","Presets"),content:H}),x&&O.push({id:"css",label:"CSS",content:X}),e.jsxs("div",{ref:k,id:A,className:`nice-field nice-gradient-field ${I?"nice-gradient--disabled":""} ${B==="left"?"nice-field--label-left":""} ${se?"nice-field--loading":""} ${oe?"nice-field--error":""} ${ce==="right"?"nice-field--error-right":""} ${i||""}`,style:o,"data-testid":F,children:[J&&e.jsx("label",{htmlFor:A,className:"nice-field__label",children:J}),e.jsxs("div",{className:"nice-field__control",children:[e.jsx("button",{ref:R,type:"button",className:"nice-gradient__swatch",style:{background:C},"aria-haspopup":"dialog","aria-expanded":D,"aria-readonly":Y||void 0,"aria-label":_("controls.openGradientEditor","Open gradient editor"),disabled:I,onClick:()=>{!I&&!Y&&j(y=>!y)}}),se&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),ce==="right"&&typeof oe=="string"&&oe&&e.jsx("div",{className:"nice-field__error",role:"alert",children:oe}),D&&h&&m&&ot.createPortal(e.jsx("div",{ref:z,className:`nice-gradient__popup${p?` ${p}`:""}`,"data-theme":p==="nice-dark"?"dark":p==="nice-light"?"light":void 0,role:"dialog","aria-label":_("controls.gradientEditor","Gradient editor"),style:{position:"fixed",left:h.left,top:h.top,width:Z!=null?typeof Z=="number"?`${Z}px`:Z:340,zIndex:1e3},children:e.jsxs("div",{className:"nice-gradient nice-gradient--studio",children:[e.jsxs("div",{className:"nice-gradient__popup-header",children:[e.jsx("div",{className:"nice-gradient__preview",style:{background:C}}),e.jsx("button",{type:"button",className:"nice-gradient__confirm",onClick:()=>j(!1),"aria-label":_("controls.confirm","Confirm"),title:_("controls.confirm","Confirm"),children:e.jsx(r.NiceIcon,{name:"check",size:18})})]}),e.jsx(pt.NiceTabs,{tabs:O,variant:"enclosed",size:"sm"})]})}),m)]}),ce!=="right"&&typeof oe=="string"&&oe&&e.jsx("div",{className:"nice-field__error",role:"alert",children:oe})]})}),{displayName:"NiceGradientPicker"}),li=[{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"}],di=[{style:"professional",label:"Professional"},{style:"casual",label:"Casual"},{style:"formal",label:"Formal"},{style:"concise",label:"Concise"}],mi=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:s,enableImprove:g=!0,enableTranslate:x=!0,enableGenerate:$=!0,toolbar:P,languages:M=li,textStyles:W=di,onImprove:J,onTranslate:B,onGenerate:I,showAIToolbar:q=!0,value:se,onChange:oe,...ce}=i,Z=n.useRef(null),[F,k]=n.useState(!1),[l,T]=n.useState(!1),[Y,A]=n.useState(!1),[_,b]=n.useState(""),[C,f]=n.useState(""),[S,K]=n.useState("professional"),[w,d]=n.useState(""),[D,j]=n.useState(M[0]?.code||"en"),[h,c]=n.useState(""),[p,E]=n.useState(""),{t:N}=an.useNiceTranslation(),m=r.useNiceAI(),{improveText:R,translate:z,generateHtml:ie,isLoading:v}=r.useTextImprovement(),ee=a&&m.isConfigured,U=n.useCallback(()=>{const ae=window.getSelection();return ae&&ae.toString().trim()?ae.toString():""},[]),me=n.useCallback(ae=>{const ve=window.getSelection();if(ve&&ve.rangeCount>0){const _e=ve.getRangeAt(0);_e.deleteContents();const te=document.createElement("div");te.innerHTML=ae;const we=document.createDocumentFragment();for(;te.firstChild;)we.appendChild(te.firstChild);if(_e.insertNode(we),Z.current){const re=Z.current.innerHTML;oe?.(re)}}},[oe]),pe=n.useCallback(async(ae="professional")=>{if(!ee||!g)return"";const ve=U();if(!ve)return"";b(ve),K(ae),k(!0),f("");try{const _e=await R(ve,ae);return f(_e),J?.(ve,_e,ae),_e}catch{return f(N("htmlEditorAI.improveFailed","Failed to improve text")),""}},[ee,g,U,R,J,N]),ye=n.useCallback(async ae=>{if(!ee||!x)return"";const ve=U();if(!ve)return"";b(ve),j(ae),T(!0),d("");try{const _e=M.find(we=>we.code===ae)?.label||ae,te=await z(ve,_e);return d(te),B?.(ve,te,ae),te}catch{return d(N("htmlEditorAI.translateFailed","Failed to translate text")),""}},[ee,x,U,z,M,B,N]),ue=n.useCallback(async ae=>{if(!ee||!$||!ae.trim())return"";c(ae),E("");try{const ve=await ie(ae);return E(ve),I?.(ae,ve),ve}catch{return E(N("htmlEditorAI.generateFailed","Failed to generate HTML")),""}},[ee,$,ie,I,N]),he=n.useCallback(()=>{C&&me(C),k(!1),f("")},[C,me]),de=n.useCallback(()=>{w&&me(w),T(!1),d("")},[w,me]),ge=n.useCallback(()=>{if(p&&Z.current){document.execCommand("insertHTML",!1,p);const ae=Z.current.innerHTML;oe?.(ae)}A(!1),E(""),c("")},[p,oe]);return n.useImperativeHandle(o,()=>({getEditor:()=>Z.current,focus:()=>Z.current?.focus(),getValue:()=>Z.current?.innerHTML||"",setValue:ae=>{Z.current&&(Z.current.innerHTML=ae,oe?.(ae))},getSelection:U,insertHtml:ae=>{document.execCommand("insertHTML",!1,ae),Z.current&&oe?.(Z.current.innerHTML)},improveSelection:pe,translateSelection:ye,generateHtml:ue})),n.useCallback(ae=>{Z.current=ae},[]),e.jsxs("div",{className:"nice-html-editor-ai","data-testid":i["data-testid"],children:[q&&ee&&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:N("htmlEditorAI.ai","AI")}),v&&e.jsx("span",{className:"nice-html-editor-ai__loading",children:N("htmlEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-html-editor-ai__toolbar-right",children:[g&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>pe(),disabled:v,title:N("htmlEditorAI.improveText","Improve selected text"),children:[e.jsx(r.NiceIcon,{name:"star",size:14})," ",N("htmlEditorAI.improve","Improve")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu",children:W.map(({style:ae,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>pe(ae),children:ve},ae))})]}),x&&e.jsxs("div",{className:"nice-html-editor-ai__dropdown",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",disabled:v,title:N("htmlEditorAI.translateText","Translate selected text"),children:[e.jsx(r.NiceIcon,{name:"globe",size:14})," ",N("htmlEditorAI.translate","Translate")]}),e.jsx("div",{className:"nice-html-editor-ai__dropdown-menu nice-html-editor-ai__dropdown-menu--languages",children:M.map(({code:ae,label:ve})=>e.jsx("button",{type:"button",className:"nice-html-editor-ai__dropdown-item",onClick:()=>ye(ae),children:ve},ae))})]}),$&&e.jsxs("button",{type:"button",className:"nice-html-editor-ai__btn",onClick:()=>A(!0),disabled:v,title:N("htmlEditorAI.generateHtml","Generate HTML from description"),children:[e.jsx(r.NiceIcon,{name:"zap",size:14})," ",N("htmlEditorAI.generate","Generate")]})]})]}),e.jsx("div",{className:"nice-html-editor-ai__editor-wrapper",children:e.jsx(sn.NiceHtmlEditor,{value:se,onChange:oe,toolbar:P,...ce})}),F&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"star",size:16})," ",N("htmlEditorAI.improveText","Improve Text")]}),e.jsx("div",{className:"nice-html-editor-ai__style-selector",children:W.map(({style:ae,label:ve})=>e.jsx("button",{type:"button",className:`nice-html-editor-ai__style-btn ${S===ae?"nice-html-editor-ai__style-btn--active":""}`,onClick:()=>{K(ae),pe(ae)},children:ve},ae))}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>k(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:N("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:N("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:_})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--improved",children:[e.jsx("h5",{children:N("htmlEditorAI.improved","Improved")}),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:he,disabled:!C||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{k(!1),f("")},children:N("htmlEditorAI.cancel","Cancel")})]})]}),l&&e.jsxs("div",{className:"nice-html-editor-ai__panel",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"globe",size:16})," ",N("htmlEditorAI.translateText","Translate Text")]}),e.jsx("div",{className:"nice-html-editor-ai__language-selector",children:e.jsx("select",{value:D,onChange:ae=>{j(ae.target.value),ye(ae.target.value)},className:"nice-html-editor-ai__language-select",children:M.map(({code:ae,label:ve})=>e.jsx("option",{value:ae,children:ve},ae))})}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>T(!1),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-html-editor-ai__panel-body",children:v?e.jsx("div",{className:"nice-html-editor-ai__loading-panel",children:N("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:N("htmlEditorAI.original","Original")}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:_})]}),e.jsxs("div",{className:"nice-html-editor-ai__text-block nice-html-editor-ai__text-block--translated",children:[e.jsx("h5",{children:M.find(ae=>ae.code===D)?.label||D}),e.jsx("div",{className:"nice-html-editor-ai__text-content",children:w})]})]})}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:de,disabled:!w||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.apply","Apply")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{T(!1),d("")},children:N("htmlEditorAI.cancel","Cancel")})]})]}),Y&&e.jsxs("div",{className:"nice-html-editor-ai__panel nice-html-editor-ai__panel--generate",children:[e.jsxs("div",{className:"nice-html-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"zap",size:16})," ",N("htmlEditorAI.generateHtml","Generate HTML")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__close","aria-label":N("htmlEditorAI.close","Close"),onClick:()=>{A(!1),E(""),c("")},children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-body",children:[e.jsxs("div",{className:"nice-html-editor-ai__generate-input",children:[e.jsx("textarea",{placeholder:N("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:h,onChange:ae=>c(ae.target.value),className:"nice-html-editor-ai__generate-textarea",rows:3}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__generate-btn",onClick:()=>ue(h),disabled:v||!h.trim(),children:v?N("htmlEditorAI.generating","Generating..."):N("htmlEditorAI.generate","Generate")})]}),p&&e.jsxs("div",{className:"nice-html-editor-ai__generate-result",children:[e.jsx("h5",{children:N("htmlEditorAI.preview","Preview")}),e.jsx("div",{className:"nice-html-editor-ai__preview",dangerouslySetInnerHTML:{__html:p}}),e.jsx("h5",{children:N("htmlEditorAI.htmlCode","HTML Code")}),e.jsx("pre",{className:"nice-html-editor-ai__code",children:p})]})]}),e.jsxs("div",{className:"nice-html-editor-ai__panel-footer",children:[e.jsxs("button",{type:"button",className:"nice-html-editor-ai__apply",onClick:ge,disabled:!p||v,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",N("htmlEditorAI.insert","Insert")]}),e.jsx("button",{type:"button",className:"nice-html-editor-ai__cancel",onClick:()=>{A(!1),E(""),c("")},children:N("htmlEditorAI.cancel","Cancel")})]})]})]})}),ui=[{target:".nice-md-editor",titleKey:"tutorial.markdownEditor.intro.title",title:"Markdown editor",contentKey:"tutorial.markdownEditor.intro.content",content:"Write Markdown with the formatting toolbar; toggle the live preview to see the rendered result, and export to HTML.",placement:"auto"}];function jn(t){let i=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return i=i.replace(/```(\w*)\n([\s\S]*?)```/g,(o,a,s)=>`<pre><code class="language-${a}">${s.trim()}</code></pre>`),i=i.replace(/^(\|.+\|)\n(\|[-| :]+\|)\n((?:\|.+\|\n?)+)/gm,(o,a,s,g)=>{const x=a.split("|").filter(P=>P.trim()).map(P=>`<th>${P.trim()}</th>`).join(""),$=g.trim().split(`
|
|
2
|
+
`).map(P=>`<tr>${P.split("|").filter(W=>W.trim()).map(W=>`<td>${W.trim()}</td>`).join("")}</tr>`).join("");return`<table><thead><tr>${x}</tr></thead><tbody>${$}</tbody></table>`}),i=i.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),i=i.replace(/^### (.+)$/gm,"<h3>$1</h3>"),i=i.replace(/^## (.+)$/gm,"<h2>$1</h2>"),i=i.replace(/^# (.+)$/gm,"<h1>$1</h1>"),i=i.replace(/^> (.+)$/gm,"<blockquote>$1</blockquote>"),i=i.replace(/^---$/gm,"<hr/>"),i=i.replace(/^- \[x\] (.+)$/gm,'<li class="task done"><input type="checkbox" checked disabled> $1</li>'),i=i.replace(/^- \[ \] (.+)$/gm,'<li class="task"><input type="checkbox" disabled> $1</li>'),i=i.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),i=i.replace(/\*(.+?)\*/g,"<em>$1</em>"),i=i.replace(/~~(.+?)~~/g,"<del>$1</del>"),i=i.replace(/`(.+?)`/g,"<code>$1</code>"),i=i.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" style="max-width:100%"/>'),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),i=i.replace(/^- (.+)$/gm,"<li>$1</li>"),i=i.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),i=i.replace(/\n/g,"<br/>"),i}const pi=[{key:"bold",label:"B",md:"**",tip:"Bold",shortcut:"Ctrl+B",group:"format"},{key:"italic",label:"I",md:"*",tip:"Italic",shortcut:"Ctrl+I",group:"format"},{key:"strike",icon:"type",md:"~~",tip:"Strikethrough",group:"format"},{key:"code",label:"< >",md:"`",tip:"Inline code",group:"format"},{key:"h1",label:"H1",md:"# ",tip:"Heading 1",group:"heading"},{key:"h2",label:"H2",md:"## ",tip:"Heading 2",group:"heading"},{key:"h3",label:"H3",md:"### ",tip:"Heading 3",group:"heading"},{key:"ul",icon:"list",md:"- ",tip:"Unordered list",group:"list"},{key:"ol",label:"1.",md:"1. ",tip:"Ordered list",group:"list"},{key:"task",icon:"check-square",md:"- [ ] ",tip:"Task list",group:"list"},{key:"quote",icon:"message",md:"> ",tip:"Blockquote",group:"block"},{key:"hr",icon:"minus",md:`---
|
|
3
3
|
`,tip:"Horizontal rule",group:"block"},{key:"link",icon:"link",md:"[](url)",tip:"Link",shortcut:"Ctrl+K",group:"insert"},{key:"image",icon:"image",md:"",tip:"Image",group:"insert"},{key:"table",icon:"table",md:`| H1 | H2 | H3 |
|
|
4
4
|
| --- | --- | --- |
|
|
5
5
|
| c1 | c2 | c3 |
|
|
6
|
-
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],
|
|
6
|
+
`,tip:"Table",group:"insert"},{key:"codeblock",label:"```",md:"```\n",tip:"Code block",group:"insert"}],hi=["format","heading","list","block","insert"],vn=Object.assign(n.forwardRef(({value:t="",onChange:i,preview:o="side",placeholder:a,disabled:s,readOnly:g,size:x="md",editorSize:$="standard",toolbar:P=!0,minHeight:M=200,showWordCount:W=!1,showLineNumbers:J=!1,onExportHtml:B,onImageUpload:I,tutorial:q,className:se,style:oe,id:ce,"data-testid":Z},F)=>{const{t:k}=r.useNiceTranslation(),l=r.useControlId(ce),[T,Y]=n.useState("edit"),[A,_]=n.useState(!1),b=n.useRef(null),[C]=n.useState(r.createTabEscape),f=n.useMemo(()=>jn(t),[t]),S=n.useMemo(()=>{const c=t.trim()?t.trim().split(/\s+/).length:0,p=t.length,E=t.split(`
|
|
7
7
|
`).length;return{words:c,chars:p,lines:E}},[t]),K=n.useCallback(c=>{const p=b.current;if(!p)return;const E=p.selectionStart,N=p.selectionEnd,m=t.slice(E,N);let R,z;c==="[](url)"?(R=t.slice(0,E)+`[${m||"text"}](url)`+t.slice(N),z=E+1+(m||"text").length+2):c===""?(R=t.slice(0,E)+``+t.slice(N),z=E+2+(m||"alt").length+2):c.endsWith(`
|
|
8
8
|
`)||c.endsWith(" ")?(R=t.slice(0,E)+c+m+t.slice(N),z=E+c.length+m.length):(R=t.slice(0,E)+c+m+c+t.slice(N),z=E+c.length+m.length+c.length),i?.(R),requestAnimationFrame(()=>{p.focus(),p.setSelectionRange(z,z)})},[t,i]),w=n.useCallback(c=>{if(!C(c)&&((c.ctrlKey||c.metaKey)&&(c.key==="b"?(c.preventDefault(),K("**")):c.key==="i"?(c.preventDefault(),K("*")):c.key==="k"&&(c.preventDefault(),K("[](url)"))),c.key==="Tab"&&!g)){c.preventDefault();const p=c.currentTarget,E=p.selectionStart,N=p.selectionEnd,m=" ";if(c.shiftKey){const ie=t.slice(0,E).lastIndexOf(`
|
|
9
9
|
`)+1;if(t.slice(ie,ie+m.length)===m){const v=t.slice(0,ie)+t.slice(ie+m.length);i?.(v),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=E-m.length})}}else{const R=t.slice(0,E)+m+t.slice(N);i?.(R),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=E+m.length})}}},[t,i,K,C,g]),d=n.useCallback(async c=>{if(!I)return;const p=Array.from(c.dataTransfer.files).filter(E=>E.type.startsWith("image/"));if(p.length!==0){c.preventDefault();for(const E of p){const N=await I(E),m=b.current;if(!m)continue;const R=m.selectionStart,z=`
|
|
10
|
-
`,ie=t.slice(0,R)+z+t.slice(R);i?.(ie)}}},[t,i,I]),D=o!=="tab"||T==="edit",j=o==="side"||o==="tab"&&T==="preview"||o===!0,h=`nice-md-editor nice-md-editor--${x} nice-editor--${$} nice-md-editor--preview-${o}${A?" nice-md-editor--fullscreen":""} ${se||""}`;return e.jsxs("div",{ref:F,id:l,className:h,style:{position:"relative",...oe},"data-testid":Z,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(
|
|
10
|
+
`,ie=t.slice(0,R)+z+t.slice(R);i?.(ie)}}},[t,i,I]),D=o!=="tab"||T==="edit",j=o==="side"||o==="tab"&&T==="preview"||o===!0,h=`nice-md-editor nice-md-editor--${x} nice-editor--${$} nice-md-editor--preview-${o}${A?" nice-md-editor--fullscreen":""} ${se||""}`;return e.jsxs("div",{ref:F,id:l,className:h,style:{position:"relative",...oe},"data-testid":Z,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(q,ui)})}),P&&e.jsxs("div",{className:"nice-md-editor__toolbar",children:[hi.map((c,p)=>e.jsxs(n.Fragment,{children:[p>0&&e.jsx("span",{className:"nice-md-editor__sep"}),pi.filter(E=>E.group===c).map(E=>e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:E.shortcut?`${E.tip} (${E.shortcut})`:E.tip,disabled:s||g,onClick:()=>K(E.md),"aria-label":E.tip,children:E.icon?e.jsx(r.NiceIcon,{name:E.icon,size:16}):E.label},E.key))]},c)),e.jsx("span",{className:"nice-md-editor__sep"}),e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:k("markdownEditor.fullscreen","Fullscreen"),"aria-label":k("markdownEditor.fullscreen","Fullscreen"),onClick:()=>_(!A),children:e.jsx(r.NiceIcon,{name:A?"collapse":"expand",size:16})}),B&&e.jsx("button",{type:"button",className:"nice-md-editor__btn",title:k("markdownEditor.exportHtml","Export HTML"),"aria-label":k("markdownEditor.exportHtml","Export HTML"),onClick:()=>B(f),children:e.jsx(r.NiceIcon,{name:"external-link",size:16})}),o==="tab"&&e.jsxs("span",{className:"nice-md-editor__tabs",children:[e.jsx("button",{type:"button",className:`nice-md-editor__tab${T==="edit"?" nice-md-editor__tab--active":""}`,onClick:()=>Y("edit"),children:k("markdownEditor.edit","Edit")}),e.jsx("button",{type:"button",className:`nice-md-editor__tab${T==="preview"?" nice-md-editor__tab--active":""}`,onClick:()=>Y("preview"),children:k("markdownEditor.preview","Preview")})]})]}),e.jsxs("div",{className:"nice-md-editor__body",style:{minHeight:M},children:[D&&e.jsxs("div",{className:"nice-md-editor__editor-wrap",children:[J&&e.jsx("div",{className:"nice-md-editor__line-numbers",children:Array.from({length:S.lines},(c,p)=>e.jsx("div",{className:"nice-md-editor__line-no",children:p+1},p))}),e.jsx("textarea",{ref:b,className:"nice-md-editor__textarea",value:t,onChange:c=>i?.(c.target.value),onKeyDown:w,onDrop:d,placeholder:a,disabled:s,readOnly:g,style:{minHeight:M},"aria-describedby":g?void 0:`${l}-tab-hint`}),!g&&e.jsx("span",{id:`${l}-tab-hint`,className:"nice-sr-only",children:k("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")})]}),j&&e.jsx("div",{className:"nice-md-editor__preview",dangerouslySetInnerHTML:{__html:r.sanitizeHtml(f)},style:{minHeight:M}})]}),W&&e.jsxs("div",{className:"nice-md-editor__statusbar",children:[e.jsx("span",{children:k("markdownEditor.words","{words} words").replace("{words}",String(S.words))}),e.jsx("span",{children:k("markdownEditor.chars","{chars} chars").replace("{chars}",String(S.chars))}),e.jsx("span",{children:k("markdownEditor.lines","{lines} lines").replace("{lines}",String(S.lines))})]})]})}),{displayName:"NiceMarkdownEditor"}),gi=[{target:".nice-doc-editor",titleKey:"tutorial.documentEditor.intro.title",title:"Document editor",contentKey:"tutorial.documentEditor.intro.content",content:"Compose a document from blocks: use the toolbar or slash commands to add headings, lists, media and more, then export to HTML.",placement:"auto"}];let fi=0;function At(){return`blk-${++fi}-${Date.now().toString(36)}`}function Gt(t=""){return{id:At(),type:"paragraph",content:t}}function yi(t,i=""){const o={id:At(),type:t,content:i};return t==="heading"&&(o.level=2),t==="list"&&(o.listType="unordered"),t==="toggle"&&(o.open=!0),o}const xi=[{type:"paragraph",label:"Text",icon:"align-left",keywords:"paragraph text"},{type:"heading",label:"Heading",icon:"type",keywords:"heading title"},{type:"list",label:"Bulleted list",icon:"list",keywords:"bullet unordered list"},{type:"list",label:"Numbered list",icon:"list-ordered",keywords:"numbered ordered list"},{type:"list",label:"Checklist",icon:"check-square",keywords:"check todo list"},{type:"quote",label:"Quote",icon:"quote",keywords:"quote blockquote"},{type:"callout",label:"Callout",icon:"info",keywords:"callout info alert"},{type:"toggle",label:"Toggle",icon:"chevron-right",keywords:"toggle collapse expand"},{type:"code",label:"Code",icon:"code",keywords:"code snippet"},{type:"image",label:"Image",icon:"image",keywords:"image photo picture"},{type:"video",label:"Video",icon:"video",keywords:"video embed"},{type:"table",label:"Table",icon:"table",keywords:"table grid"},{type:"divider",label:"Divider",icon:"minus",keywords:"divider line separator"},{type:"pageBreak",label:"Page Break",icon:"page-break",keywords:"page break"}];function lt(t){return t.type==="toggle"?t.content.split(`
|
|
11
11
|
`).slice(1).join(`
|
|
12
|
-
`):t.content}function
|
|
12
|
+
`):t.content}function bi(t){const i=[t.align?`text-align:${t.align}`:"",t.color?`color:${t.color}`:"",t.bgColor?`background-color:${t.bgColor}`:"",t.indent?`margin-left:${t.indent*24}px`:""].filter(Boolean).join(";"),o=i?` style="${i}"`:"",a=(s,g)=>{let x=g;return t.bold&&(x=`<strong>${x}</strong>`),t.italic&&(x=`<em>${x}</em>`),t.underline&&(x=`<u>${x}</u>`),t.strikethrough&&(x=`<s>${x}</s>`),`<${s}${o}>${x}</${s}>`};switch(t.type){case"heading":return a(`h${t.level??2}`,t.content);case"paragraph":return a("p",t.content||" ");case"list":{const s=t.listType==="ordered"?"ol":"ul",g=t.content.split(`
|
|
13
13
|
`).map((x,$)=>t.listType==="checklist"?`<li><input type="checkbox" ${t.checked?.[$]??!1?"checked":""} disabled />${x}</li>`:`<li>${x}</li>`).join("");return`<${s}${o}>${g}</${s}>`}case"image":return`<figure${o}><img src="${t.src??""}" alt="${t.alt??""}" /></figure>`;case"video":return`<figure${o}><video src="${t.src??""}" controls></video></figure>`;case"divider":return"<hr />";case"pageBreak":return'<div style="page-break-after:always"></div>';case"code":return`<pre><code class="language-${t.language??""}">${t.content}</code></pre>`;case"quote":return a("blockquote",t.content);case"callout":return`<div class="nice-doc-callout"${o}>${t.icon?`<span>${t.icon}</span>`:""}<div>${t.content}</div></div>`;case"toggle":return`<details${o}><summary>${t.content.split(`
|
|
14
14
|
`)[0]}</summary>${t.content.split(`
|
|
15
|
-
`).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return a("p",t.content)}}function
|
|
15
|
+
`).slice(1).join("<br>")}</details>`;case"table":return`<table${o}>${t.content}</table>`;case"embed":return`<iframe src="${t.src??""}" style="width:100%;border:none;min-height:300px"></iframe>`;default:return a("p",t.content)}}function ji(t){let i=0,o=0;for(const a of t){const s=a.content??"";i+=s.length;const g=s.trim().split(/\s+/).filter(Boolean);o+=g.length}return{words:o,chars:i,readingTime:Math.max(1,Math.ceil(o/200))}}const vi=Object.assign(n.forwardRef(({blocks:t,onChange:i,readOnly:o=!1,showToolbar:a=!0,size:s="md",editorSize:g="standard",placeholder:x,onExport:$,onImageUpload:P,maxUndo:M=50,slashCommands:W=!0,showWordCount:J=!1,showToc:B=!1,showFindReplace:I=!0,tutorial:q,className:se,style:oe,id:ce,...Z},F)=>{const k=r.useControlId(ce),{t:l}=r.useNiceTranslation(),[T]=n.useState(r.createTabEscape),Y=`${k}-tab-hint`,A=n.useRef(null);r.useRovingFocus(A,{orientation:"horizontal",itemSelector:"button"});const[_,b]=n.useState(()=>t??[Gt()]),C=t??_,[f,S]=n.useState(0),K=n.useRef(new Map),w=n.useRef(null),d=n.useRef(new Map),D=(u,V)=>{const L=d.current.get(u);return L!==void 0?L:(d.current.set(u,V),V)};n.useLayoutEffect(()=>{for(const u of C){const V=K.current.get(u.id);if(!V||!V.isConnected||V.getAttribute("contenteditable")===null)continue;const L=lt(u);V.textContent!==L&&(V.textContent=L)}});const[j,h]=n.useState(!1),[c,p]=n.useState(""),[E,N]=n.useState(""),[m,R]=n.useState([]),[z,ie]=n.useState(0),[v,ee]=n.useState(!1),U=n.useRef([]),me=n.useRef([]),pe=n.useCallback(u=>{U.current.push(u.map(V=>({...V,checked:V.checked?[...V.checked]:void 0}))),U.current.length>M&&U.current.shift(),me.current=[]},[M]),ye=n.useCallback(()=>{if(U.current.length===0)return;const u=U.current.pop();me.current.push(C.map(V=>({...V}))),t||b(u),i?.(u)},[C,t,i]),ue=n.useCallback(()=>{if(me.current.length===0)return;const u=me.current.pop();U.current.push(C.map(V=>({...V}))),t||b(u),i?.(u)},[C,t,i]),[he,de]=n.useState(!1),[ge,ae]=n.useState(""),[ve,_e]=n.useState(0),te=n.useMemo(()=>{if(!he||!W)return[];const u=ge.toLowerCase();return xi.filter(V=>V.label.toLowerCase().includes(u)||V.keywords.includes(u))},[he,ge,W]),[we,re]=n.useState(null),[fe,H]=n.useState(null),X=n.useCallback(u=>{pe(C);const V=u(C);t||b(V),i?.(V)},[C,t,i,pe]),O=n.useCallback((u,V)=>{X(L=>L.map((ke,Ce)=>Ce===u?{...ke,...V}:ke))},[X]),y=n.useCallback((u,V)=>{const L=V??Gt();X(ke=>{const Ce=[...ke];return Ce.splice(u+1,0,L),Ce}),S(u+1)},[X]),G=n.useCallback(u=>{const V={...C[u],id:At()};y(u,V)},[C,y]),ne=n.useCallback(u=>{C.length<=1||(X(V=>V.filter((L,ke)=>ke!==u)),S(Math.max(0,u-1)))},[C.length,X]),le=n.useCallback((u,V)=>{const L=u+V;L<0||L>=C.length||(X(ke=>{const Ce=[...ke];return[Ce[u],Ce[L]]=[Ce[L],Ce[u]],Ce}),S(L))},[C.length,X]),be=n.useCallback((u,V)=>{const L={type:V};V==="heading"&&(L.level=2),V==="list"&&(L.listType="unordered"),V==="toggle"&&(L.open=!0),O(u,L)},[O]),xe=n.useCallback(u=>{const V=yi(u.type);u.type==="list"&&u.label.includes("Numbered")&&(V.listType="ordered"),u.type==="list"&&u.label.includes("Checklist")&&(V.listType="checklist",V.checked=[]),C[f]?.content===""||C[f]?.content==="/"?X(L=>L.map((ke,Ce)=>Ce===f?{...V,id:ke.id}:ke)):y(f,V),de(!1),ae("")},[C,f,X,y]),Se=n.useCallback((u,V)=>{if(T(u)||o)return;const L=C[V];if(!L?.locked){if((u.ctrlKey||u.metaKey)&&u.key==="z"&&!u.shiftKey){u.preventDefault(),ye();return}if((u.ctrlKey||u.metaKey)&&(u.key==="y"||u.key==="z"&&u.shiftKey)){u.preventDefault(),ue();return}if((u.ctrlKey||u.metaKey)&&u.key==="d"){u.preventDefault(),G(V);return}if((u.ctrlKey||u.metaKey)&&u.key==="b"){u.preventDefault(),O(V,{bold:!L?.bold});return}if((u.ctrlKey||u.metaKey)&&u.key==="i"){u.preventDefault(),O(V,{italic:!L?.italic});return}if((u.ctrlKey||u.metaKey)&&u.key==="u"){u.preventDefault(),O(V,{underline:!L?.underline});return}if((u.ctrlKey||u.metaKey)&&u.key==="e"){u.preventDefault(),O(V,{strikethrough:!L?.strikethrough});return}if(u.key==="Tab"&&!u.shiftKey){u.preventDefault(),O(V,{indent:Math.min((L?.indent??0)+1,4)});return}if(u.key==="Tab"&&u.shiftKey){u.preventDefault(),O(V,{indent:Math.max((L?.indent??0)-1,0)});return}if((u.ctrlKey||u.metaKey)&&u.key==="f"&&I){u.preventDefault(),h(ke=>!ke);return}if(he&&te.length>0){if(u.key==="ArrowDown"){u.preventDefault(),_e(ke=>Math.min(ke+1,te.length-1));return}if(u.key==="ArrowUp"){u.preventDefault(),_e(ke=>Math.max(ke-1,0));return}if(u.key==="Enter"){u.preventDefault(),xe(te[ve]);return}if(u.key==="Escape"){de(!1);return}}u.key==="Enter"&&!u.shiftKey?(u.preventDefault(),y(V)):u.key==="Backspace"&&C[V].content===""&&C.length>1?(u.preventDefault(),ne(V)):u.key==="ArrowUp"&&u.altKey?(u.preventDefault(),le(V,-1)):u.key==="ArrowDown"&&u.altKey&&(u.preventDefault(),le(V,1))}},[T,o,C,y,ne,le,ye,ue,G,O,he,te,ve,xe,I]),Te=n.useCallback((u,V)=>{const L=u.target.textContent??"";W&&L.startsWith("/")?(de(!0),ae(L.slice(1)),_e(0)):he&&de(!1),pe(C);const ke=C.map((Ce,Pe)=>Pe===V?{...Ce,content:Ce.type==="toggle"?`${Ce.content.split(`
|
|
16
16
|
`)[0]}
|
|
17
|
-
${L}`:L}:Ce);t||b(ke),i?.(ke)},[C,t,i,pe,W,he]),Me=n.useCallback((u,V)=>{re(V),u.dataTransfer.effectAllowed="move"},[]),ze=n.useCallback((u,V)=>{u.preventDefault(),u.dataTransfer.dropEffect="move",H(V)},[]),qe=n.useCallback((u,V)=>{if(u.preventDefault(),we===null||we===V){re(null),H(null);return}
|
|
18
|
-
`);$?.(u)},[C,$]),Le=n.useMemo(()=>J?vi(C):null,[C,J]),[Ae,Oe]=n.useState(null),st=n.useCallback((u,V)=>{o||(u.preventDefault(),Oe({x:u.clientX,y:u.clientY,idx:V}))},[o]);return n.useEffect(()=>{if(!Ae)return;const u=()=>Oe(null);return window.addEventListener("click",u),()=>window.removeEventListener("click",u)},[Ae]),e.jsxs("div",{ref:F,id:k,className:`nice-doc-editor nice-doc-editor--${s} nice-editor--${g} ${o?"nice-doc-editor--readonly":""} ${se??""}`,style:{position:"relative",...oe},role:"application","aria-label":l("docEditor.label","Document Editor"),...Z,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(X,fi)})}),a&&!o&&e.jsxs("div",{ref:A,className:"nice-doc-editor__toolbar",role:"toolbar","aria-label":l("docEditor.toolbar","Formatting"),style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:ye,title:l("docEditor.undo","Undo (Ctrl+Z)"),ariaLabel:l("docEditor.undo","Undo (Ctrl+Z)"),children:e.jsx(r.NiceIcon,{name:"undo",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:ue,title:l("docEditor.redo","Redo (Ctrl+Y)"),ariaLabel:l("docEditor.redo","Redo (Ctrl+Y)"),children:e.jsx(r.NiceIcon,{name:"redo",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(et.NiceSelect,{size:"sm",value:C[f]?.type??"paragraph",onChange:u=>be(f,u),label:"",options:[{value:"paragraph",label:l("docEditor.paragraph","Paragraph")},{value:"heading",label:l("docEditor.heading","Heading")},{value:"list",label:l("docEditor.list","List")},{value:"code",label:l("docEditor.code","Code")},{value:"quote",label:l("docEditor.quote","Quote")},{value:"callout",label:l("docEditor.callout","Callout")},{value:"toggle",label:l("docEditor.toggle","Toggle")},{value:"divider",label:l("docEditor.divider","Divider")},{value:"image",label:l("docEditor.image","Image")},{value:"video",label:l("docEditor.video","Video")},{value:"pageBreak",label:l("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),C[f]?.type==="heading"&&e.jsx(et.NiceSelect,{size:"sm",value:String(C[f]?.level??2),onChange:u=>O(f,{level:Number(u)}),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}}),C[f]?.type==="list"&&e.jsx(et.NiceSelect,{size:"sm",value:C[f]?.listType??"unordered",onChange:u=>O(f,{listType:u}),label:"",options:[{value:"unordered",label:l("docEditor.bullets","Bullets")},{value:"ordered",label:l("docEditor.numbers","Numbers")},{value:"checklist",label:l("docEditor.checklist","Checklist")}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.bold?"primary":"ghost",onClick:()=>O(f,{bold:!C[f]?.bold}),title:l("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.italic?"primary":"ghost",onClick:()=>O(f,{italic:!C[f]?.italic}),title:l("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.underline?"primary":"ghost",onClick:()=>O(f,{underline:!C[f]?.underline}),title:l("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.strikethrough?"primary":"ghost",onClick:()=>O(f,{strikethrough:!C[f]?.strikethrough}),title:l("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="left"?"primary":"ghost",onClick:()=>O(f,{align:"left"}),title:l("docEditor.alignLeft","Left"),ariaLabel:l("docEditor.alignLeft","Left"),children:e.jsx(r.NiceIcon,{name:"align-left",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="center"?"primary":"ghost",onClick:()=>O(f,{align:"center"}),title:l("docEditor.alignCenter","Center"),ariaLabel:l("docEditor.alignCenter","Center"),children:e.jsx(r.NiceIcon,{name:"align-center",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="right"?"primary":"ghost",onClick:()=>O(f,{align:"right"}),title:l("docEditor.alignRight","Right"),ariaLabel:l("docEditor.alignRight","Right"),children:e.jsx(r.NiceIcon,{name:"align-right",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(f,{indent:Math.min((C[f]?.indent??0)+1,4)}),title:l("docEditor.indent","Indent (Tab)"),ariaLabel:l("docEditor.indent","Indent (Tab)"),children:e.jsx(r.NiceIcon,{name:"indent",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(f,{indent:Math.max((C[f]?.indent??0)-1,0)}),title:l("docEditor.outdent","Outdent (Shift+Tab)"),ariaLabel:l("docEditor.outdent","Outdent (Shift+Tab)"),children:e.jsx(r.NiceIcon,{name:"outdent",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ot.NiceColorPicker,{size:"sm",label:"",value:C[f]?.color??"var(--nice-text-primary, #000000)",onChange:u=>O(f,{color:u}),title:l("docEditor.textColor","Text color")}),e.jsx(Ot.NiceColorPicker,{size:"sm",label:"",value:C[f]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:u=>O(f,{bgColor:u}),title:l("docEditor.blockBackground","Block background")}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.locked?"primary":"ghost",onClick:()=>O(f,{locked:!C[f]?.locked}),title:l("docEditor.lock","Lock/Unlock block"),ariaLabel:l("docEditor.lock","Lock/Unlock block"),children:e.jsx(r.NiceIcon,{name:C[f]?.locked?"lock":"unlock",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>G(f),title:l("docEditor.duplicate","Duplicate (Ctrl+D)"),ariaLabel:l("docEditor.duplicate","Duplicate (Ctrl+D)"),children:e.jsx(r.NiceIcon,{name:"copy",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ne(f),title:l("docEditor.delete","Delete block"),ariaLabel:l("docEditor.delete","Delete block"),children:e.jsx(r.NiceIcon,{name:"trash",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>y(f),title:l("docEditor.addBlock","Add block"),ariaLabel:l("docEditor.addBlock","Add block"),children:e.jsx(r.NiceIcon,{name:"plus",size:"sm"})}),I&&e.jsx(Ie.NiceButton,{size:"sm",variant:j?"primary":"ghost",onClick:()=>h(u=>!u),title:l("docEditor.find","Find & Replace (Ctrl+F)"),ariaLabel:l("docEditor.find","Find & Replace (Ctrl+F)"),children:e.jsx(r.NiceIcon,{name:"search",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ee(u=>!u),title:l("docEditor.shortcuts","Keyboard shortcuts"),ariaLabel:l("docEditor.shortcuts","Keyboard shortcuts"),children:e.jsx(r.NiceIcon,{name:"keyboard",size:"sm"})}),$&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Je,children:l("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:w,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:$e}),j&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)"},children:[e.jsx(ot.NiceTextInput,{size:"sm",placeholder:l("docEditor.findPlaceholder","Find..."),value:c,onChange:p,style:{flex:1,maxWidth:200}}),e.jsx(ot.NiceTextInput,{size:"sm",placeholder:l("docEditor.replacePlaceholder","Replace..."),value:E,onChange:N,style:{flex:1,maxWidth:200}}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ve,title:l("docEditor.findPrev","Previous"),ariaLabel:l("docEditor.findPrev","Previous"),children:e.jsx(r.NiceIcon,{name:"chevron-up",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Xe,title:l("docEditor.findNext","Next"),ariaLabel:l("docEditor.findNext","Next"),children:e.jsx(r.NiceIcon,{name:"chevron-down",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ge,title:l("docEditor.replaceOne","Replace"),disabled:o,children:l("docEditor.replace","Replace")}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ee,title:l("docEditor.replaceAll","Replace all"),disabled:o,children:l("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:m.length>0?`${z+1}/${m.length}`:"0/0"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h(!1),title:l("docEditor.closeFind","Close"),ariaLabel:l("docEditor.closeFind","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:"sm"})})]}),v&&e.jsx("div",{role:"presentation",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:()=>ee(!1),children:e.jsxs("div",{role:"presentation",style:{background:"var(--nice-bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:u=>u.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:l("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",l("docEditor.bold","Bold")],["Ctrl+I",l("docEditor.italic","Italic")],["Ctrl+U",l("docEditor.underline","Underline")],["Ctrl+E",l("docEditor.strikethrough","Strikethrough")],["Ctrl+D",l("docEditor.duplicate","Duplicate block")],["Ctrl+Z",l("docEditor.undo","Undo")],["Ctrl+Y",l("docEditor.redo","Redo")],["Ctrl+F",l("docEditor.find","Find & Replace")],["Enter",l("docEditor.newBlock","New block")],["Backspace",l("docEditor.deleteEmpty","Delete empty block")],["Alt+↑",l("docEditor.moveUp","Move block up")],["Alt+↓",l("docEditor.moveDown","Move block down")],["Tab",l("docEditor.indent","Indent")],["Shift+Tab",l("docEditor.outdent","Outdent")],["Esc, Tab",l("docEditor.leaveEditor","Leave the editor")],["/",l("docEditor.slashCmd","Slash commands")]].map(([u,V])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:u}),e.jsx("td",{style:{padding:"4px 8px"},children:V})]},u))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ee(!1),children:l("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[B&&We.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--nice-text-muted, #999)"},children:l("docEditor.toc","Contents")}),We.map(u=>e.jsx("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"3px 8px",paddingLeft:8+(u.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:u.idx===f?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>S(u.idx),title:u.text,children:u.text||l("docEditor.untitled","Untitled")},u.idx))]}),e.jsxs("div",{className:"nice-doc-editor__body",style:{flex:1},children:[!o&&e.jsx("span",{id:Y,className:"nice-sr-only",children:l("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")}),C.map((u,V)=>e.jsxs("div",{role:"presentation",className:`nice-doc-editor__block nice-doc-editor__block--${u.type} ${V===f?"nice-doc-editor__block--focused":""} ${fe===V?"nice-doc-editor__block--drop-target":""} ${u.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>S(V),onContextMenu:L=>st(L,V),draggable:!o&&!u.locked,onDragStart:L=>Me(L,V),onDragOver:L=>ze(L,V),onDrop:L=>qe(L,V),onDragEnd:()=>{re(null),H(null)},style:{opacity:we===V?.4:1,marginLeft:(u.indent??0)*24},children:[!o&&!u.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:l("docEditor.drag","Drag to reorder"),children:e.jsx(r.NiceIcon,{name:"grip",size:"sm"})}),u.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:e.jsx(r.NiceIcon,{name:"lock",size:"sm"})}),u.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):u.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--nice-text-muted, #999)"},children:["— ",l("docEditor.pageBreak","Page Break")," —"]}):u.type==="image"||u.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:u.src?u.type==="image"?e.jsx("img",{src:u.src,alt:u.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:u.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!o&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(ot.NiceTextInput,{size:"sm",placeholder:u.type==="image"?l("docEditor.imageUrl","Image URL"):l("docEditor.videoUrl","Video URL"),value:u.src??"",onChange:L=>O(V,{src:L})}),P&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{S(V),w.current?.click()},title:l("docEditor.upload","Upload file"),ariaLabel:l("docEditor.upload","Upload file"),children:e.jsx(r.NiceIcon,{name:"upload",size:"sm"})})]})}):u.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:u.bgColor??"var(--nice-info-bg, #f0f7ff)",borderRadius:4,color:u.color},children:[e.jsx("span",{style:{fontSize:"1.2em",display:"inline-flex"},children:u.icon??e.jsx(r.NiceIcon,{name:"info",size:"sm"})}),e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),"data-placeholder":l("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{flex:1,outline:"none"},children:D(u.id,dt(u))})]}):u.type==="toggle"?e.jsxs("details",{open:u.open,className:"nice-doc-editor__toggle",onToggle:L=>O(V,{open:L.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:u.content.split(`
|
|
19
|
-
`)[0]||l("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{padding:"4px 0"},children:D(u.id,dt(u))})]}):u.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(ot.NiceTextInput,{size:"sm",value:u.language??"",onChange:L=>O(V,{language:L}),placeholder:l("docEditor.language","Language"),style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:D(u.id,dt(u))})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,style:{textAlign:u.align,fontWeight:u.bold?"bold":void 0,fontStyle:u.italic?"italic":void 0,textDecoration:[u.underline?"underline":"",u.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:u.color,backgroundColor:u.bgColor},onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),"data-placeholder":!u.content&&x?x:void 0,role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,children:D(u.id,dt(u))}),he&&V===f&&te.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:te.map((L,ke)=>e.jsxs("li",{role:"presentation",className:ke===ve?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:ke===ve?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Ce=>{Ce.preventDefault(),xe(L)},onMouseEnter:()=>_e(ke),children:[e.jsx("span",{style:{width:24,display:"inline-flex",justifyContent:"center"},children:e.jsx(r.NiceIcon,{name:L.icon,size:"sm"})}),e.jsx("span",{children:L.label})]},`${L.type}-${L.label}`))})]})]},u.id))]})]}),Ae&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:Ae.x,top:Ae.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{G(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"copy",size:"sm"})," ",l("docEditor.duplicate2","Duplicate")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{y(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"plus",size:"sm"})," ",l("docEditor.insertBelow","Insert below")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{le(Ae.idx,-1),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-up",size:"sm"})," ",l("docEditor.moveUp2","Move up")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{le(Ae.idx,1),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-down",size:"sm"})," ",l("docEditor.moveDown2","Move down")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{O(Ae.idx,{locked:!C[Ae.idx]?.locked}),Oe(null)},children:[e.jsx(r.NiceIcon,{name:C[Ae.idx]?.locked?"unlock":"lock",size:"sm"})," ",C[Ae.idx]?.locked?l("docEditor.unlock","Unlock"):l("docEditor.lock2","Lock")]}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{ne(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"trash",size:"sm"})," ",l("docEditor.delete2","Delete")]})]}),J&&Le&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[Le.words," ",l("docEditor.words","words")]}),e.jsxs("span",{children:[Le.chars," ",l("docEditor.chars","characters")]}),e.jsxs("span",{children:[C.length," ",l("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Le.readingTime," ",l("docEditor.readingTime","min read")]})]})]})}),{displayName:"NiceDocumentEditor"}),ki=[];function kn(t,i){for(const o of t){if(o.id===i)return[o];const a=o.children?kn(o.children,i):[];if(a.length>0)return[o,...a]}return[]}function wn(t,i){const o=i.trim().toLowerCase();if(!o)return t;const a=[];for(const s of t){const g=s.children?wn(s.children,o):[];(s.title.toLowerCase().includes(o)||(s.content??"").toLowerCase().includes(o)||g.length>0)&&a.push({...s,children:g})}return a}const wi=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,disabled:a,readOnly:s,size:g="md",id:x,className:$,style:P,accessMode:M,pages:W=ki,selectedPageId:J,defaultSelectedPageId:B,content:I,contentFormat:X="html",editing:se,defaultEditing:oe,onPageSelect:ce,onContentChange:Z,onSave:F,onCreatePage:k,onDeletePage:l,onEditToggle:T,onVersionHistory:Y,sidebarWidth:A=260,sidebarCollapsed:_=!1,onSidebarToggle:b,searchable:C=!0,onSearch:f},S)=>{const K=r.useNiceAccessMode(M,x),w=K==="hidden";K==="disabled"&&(a=!0),K==="readOnly"&&(s=!0);const{t:d}=r.useNiceTranslation(),D=r.useControlId(x),[j,h]=n.useState(""),[c,p]=n.useState(""),[E,N]=n.useState(!1),[m,R]=r.useControllableState({value:J,defaultValue:B,fallbackValue:W[0]?.id,componentName:"NiceWiki"}),[z,ie]=r.useControllableState({value:se,defaultValue:oe,fallbackValue:!1,onChange:T,componentName:"NiceWiki"}),v=I!==void 0,[ee,U]=n.useState({}),[me,pe]=n.useState(null),ye=n.useMemo(()=>kn(W,m),[W,m]),ue=ye[ye.length-1],he=n.useMemo(()=>wn(W,j),[W,j]),de=v?I??"":ue?ee[String(ue.id)]??ue.content??"":"",ge=v?de:me??de,ae=n.useCallback(O=>{pe(null),R(O.id),ce?.(O)},[ce,R]),ve=O=>{v||pe(O),Z?.(O)},_e=()=>{pe(null),ie(!0)},te=()=>{pe(null),ie(!1)},we=()=>{ue&&(v||(U(O=>({...O,[String(ue.id)]:ge})),pe(null)),F?.(ue.id,ge),ie(!1))},re=n.useCallback(O=>{h(O),f?.(O)},[f]),fe=n.useCallback(()=>{c.trim()&&(k?.(m??null,c.trim()),p(""),N(!1))},[c,m,k]),H=n.useRef(null);r.useTreeFocus(H,{rowSelector:".nice-wiki__tree-node",onToggle:()=>{}});const q=(O,y=0)=>e.jsx("ul",{className:"nice-wiki__tree",role:y>0?"group":"none",style:{paddingLeft:y>0?16:0},children:O.map(G=>e.jsxs("li",{className:"nice-wiki__tree-item",role:"treeitem","aria-label":G.title,"aria-selected":G.id===m,children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-wiki__tree-node${G.id===m?" nice-wiki__tree-node--active":""}${G.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ae(G),children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(r.NiceIcon,{name:G.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:G.title}),G.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:d("draft","Draft")})]}),G.children&&G.children.length>0&&q(G.children,y+1)]},G.id))});return w?null:e.jsxs("div",{ref:S,id:D,className:`nice-wiki nice-size-${g}${$?` ${$}`:""}${a?" nice-disabled":""}`,style:P,children:[!_&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:A},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??d("wiki","Wiki")}),b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>b(!0),"aria-label":d("collapseSidebar","Collapse sidebar"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})})]}),C&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:j,onChange:O=>re(O.target.value),placeholder:d("searchPages","Search pages…"),disabled:a}),e.jsx("div",{ref:H,className:"nice-wiki__page-tree",role:"tree","aria-label":t??d("wiki","Wiki"),children:q(he)}),k&&!s&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:E?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:O=>p(O.target.value),placeholder:d("pageTitle","Page title"),onKeyDown:O=>O.key==="Enter"&&fe(),disabled:a}),e.jsx("button",{type:"button",disabled:a||!c.trim(),onClick:fe,"aria-label":d("create","Create"),children:e.jsx(r.NiceIcon,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>N(!1),"aria-label":d("cancel","Cancel"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>N(!0),disabled:a,children:[e.jsx(r.NiceIcon,{name:"plus",size:14})," ",d("newPage","New page")]})})]}),_&&b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>b(!1),"aria-label":d("expandSidebar","Expand sidebar"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:ue?e.jsxs(e.Fragment,{children:[ye.length>1&&e.jsx("nav",{className:"nice-wiki__breadcrumbs","aria-label":t??d("wiki","Wiki"),children:ye.map((O,y)=>y<ye.length-1?e.jsxs(n.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-wiki__breadcrumb",onClick:()=>ae(O),children:O.title}),e.jsx(r.NiceIcon,{name:"chevron-right",size:12})]},O.id):e.jsx("span",{className:"nice-wiki__breadcrumb","aria-current":"page",children:O.title},O.id))}),e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:ue.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[!s&&(z?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:a,onClick:we,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",d("save","Save")]}),e.jsx("button",{type:"button",disabled:a,onClick:te,children:d("cancel","Cancel")})]}):e.jsxs("button",{type:"button",disabled:a,onClick:_e,children:[e.jsx(r.NiceIcon,{name:"edit",size:14})," ",d("edit","Edit")]})),Y&&e.jsx("button",{type:"button",disabled:a,onClick:()=>Y(ue.id),children:d("history","History")}),l&&!s&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:a,onClick:()=>l(ue.id),children:d("delete","Delete")})]})]}),ue.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[ue.updatedBy&&e.jsxs("span",{children:[d("lastEditedBy","Last edited by")," ",ue.updatedBy]}),e.jsx("span",{children:new Date(ue.updatedAt).toLocaleDateString()})]}),z&&!s?e.jsx("div",{className:"nice-wiki__editor",children:X==="markdown"?e.jsx(_n,{value:ge,onChange:ve,preview:"side",minHeight:320,disabled:a}):e.jsx(rn.NiceHtmlEditor,{value:ge,onChange:ve,height:320,disabled:a})}):e.jsx("div",{className:"nice-wiki__viewer",children:e.jsx("div",{className:"nice-wiki__html","data-format":X,dangerouslySetInnerHTML:{__html:r.sanitizeHtml(X==="html"?de:vn(de))}})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:d("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceWiki"}),Ni=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:s,enableInlineCompletion:g=!0,completionDelay:x=500,enableExplain:$=!0,enableRefactor:P=!0,enableGenerate:M=!0,systemPrompt:W,onExplain:J,onRefactor:B,showAIToolbar:I=!0,aiShortcutKey:X="Ctrl",language:se="plaintext",value:oe,onChange:ce,onCursorPositionChange:Z,...F}=i,k=n.useRef(null),[l,T]=n.useState(null),[Y,A]=n.useState(!1),[_,b]=n.useState(""),[C,f]=n.useState(!1),[S,K]=n.useState(""),[w,d]=n.useState(""),[D,j]=n.useState(""),h=n.useRef(void 0),{t:c}=sn.useNiceTranslation(),p=r.useNiceAI(),{complete:E,explain:N,refactor:m,generateFromComment:R,isLoading:z}=r.useCodeCompletion({language:se,model:s}),ie=a&&p.isConfigured,v=n.useCallback(async()=>{if(!ie||!g||!k.current||!k.current.getEditor())return;const ge=k.current.getCursorPosition(),ve=k.current.getValue().split(`
|
|
17
|
+
${L}`:L}:Ce);t||b(ke),i?.(ke)},[C,t,i,pe,W,he]),Me=n.useCallback((u,V)=>{re(V),u.dataTransfer.effectAllowed="move"},[]),ze=n.useCallback((u,V)=>{u.preventDefault(),u.dataTransfer.dropEffect="move",H(V)},[]),qe=n.useCallback((u,V)=>{if(u.preventDefault(),we===null||we===V){re(null),H(null);return}X(L=>{const ke=[...L],[Ce]=ke.splice(we,1);return ke.splice(V>we?V-1:V,0,Ce),ke}),S(V>we?V-1:V),re(null),H(null)},[we,X]);n.useEffect(()=>{if(!j||!c){R([]);return}const u=c.toLowerCase(),V=[];C.forEach((L,ke)=>{const Ce=(L.content??"").toLowerCase();let Pe=0;for(;Pe<Ce.length;){const He=Ce.indexOf(u,Pe);if(He===-1)break;V.push({blockIdx:ke,start:He,end:He+u.length}),Pe=He+1}}),R(V),ie(0)},[c,j,C]);const Ve=n.useCallback(()=>{if(m.length===0)return;const u=(z+1)%m.length;ie(u),S(m[u].blockIdx)},[m,z]),Ge=n.useCallback(()=>{if(m.length===0)return;const u=(z-1+m.length)%m.length;ie(u),S(m[u].blockIdx)},[m,z]),We=n.useCallback(()=>{if(m.length===0||!c)return;const u=m[z],V=C[u.blockIdx],L=V.content.slice(0,u.start),ke=V.content.slice(u.end);O(u.blockIdx,{content:L+E+ke})},[m,z,c,E,C,O]),Ee=n.useCallback(()=>{if(!c)return;const u=c;X(V=>V.map(L=>({...L,content:L.content.split(u).join(E)})))},[c,E,X]),Je=n.useMemo(()=>B?C.map((u,V)=>u.type==="heading"?{idx:V,level:u.level??2,text:u.content}:null).filter(Boolean):[],[C,B]),$e=n.useCallback(async u=>{const V=u.target.files?.[0];if(V){if(P){const L=await P(V);O(f,{src:L})}u.target.value=""}},[P,f,O]);n.useEffect(()=>{const u=C[f];if(u){const V=K.current.get(u.id);V&&V.focus()}},[f,C]);const Ze=n.useCallback(()=>{const u=C.map(bi).join(`
|
|
18
|
+
`);$?.(u)},[C,$]),Le=n.useMemo(()=>J?ji(C):null,[C,J]),[Ae,Oe]=n.useState(null),at=n.useCallback((u,V)=>{o||(u.preventDefault(),Oe({x:u.clientX,y:u.clientY,idx:V}))},[o]);return n.useEffect(()=>{if(!Ae)return;const u=()=>Oe(null);return window.addEventListener("click",u),()=>window.removeEventListener("click",u)},[Ae]),e.jsxs("div",{ref:F,id:k,className:`nice-doc-editor nice-doc-editor--${s} nice-editor--${g} ${o?"nice-doc-editor--readonly":""} ${se??""}`,style:{position:"relative",...oe},role:"application","aria-label":l("docEditor.label","Document Editor"),...Z,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(q,gi)})}),a&&!o&&e.jsxs("div",{ref:A,className:"nice-doc-editor__toolbar",role:"toolbar","aria-label":l("docEditor.toolbar","Formatting"),style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"4px 8px"},children:[e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:ye,title:l("docEditor.undo","Undo (Ctrl+Z)"),ariaLabel:l("docEditor.undo","Undo (Ctrl+Z)"),children:e.jsx(r.NiceIcon,{name:"undo",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:ue,title:l("docEditor.redo","Redo (Ctrl+Y)"),ariaLabel:l("docEditor.redo","Redo (Ctrl+Y)"),children:e.jsx(r.NiceIcon,{name:"redo",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Fe.NiceSelect,{size:"sm",value:C[f]?.type??"paragraph",onChange:u=>be(f,u),label:"",options:[{value:"paragraph",label:l("docEditor.paragraph","Paragraph")},{value:"heading",label:l("docEditor.heading","Heading")},{value:"list",label:l("docEditor.list","List")},{value:"code",label:l("docEditor.code","Code")},{value:"quote",label:l("docEditor.quote","Quote")},{value:"callout",label:l("docEditor.callout","Callout")},{value:"toggle",label:l("docEditor.toggle","Toggle")},{value:"divider",label:l("docEditor.divider","Divider")},{value:"image",label:l("docEditor.image","Image")},{value:"video",label:l("docEditor.video","Video")},{value:"pageBreak",label:l("docEditor.pageBreak","Page Break")}],style:{minWidth:100}}),C[f]?.type==="heading"&&e.jsx(Fe.NiceSelect,{size:"sm",value:String(C[f]?.level??2),onChange:u=>O(f,{level:Number(u)}),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}}),C[f]?.type==="list"&&e.jsx(Fe.NiceSelect,{size:"sm",value:C[f]?.listType??"unordered",onChange:u=>O(f,{listType:u}),label:"",options:[{value:"unordered",label:l("docEditor.bullets","Bullets")},{value:"ordered",label:l("docEditor.numbers","Numbers")},{value:"checklist",label:l("docEditor.checklist","Checklist")}],style:{minWidth:90}}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.bold?"primary":"ghost",onClick:()=>O(f,{bold:!C[f]?.bold}),title:l("docEditor.bold","Bold (Ctrl+B)"),children:e.jsx("strong",{children:"B"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.italic?"primary":"ghost",onClick:()=>O(f,{italic:!C[f]?.italic}),title:l("docEditor.italic","Italic (Ctrl+I)"),children:e.jsx("em",{children:"I"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.underline?"primary":"ghost",onClick:()=>O(f,{underline:!C[f]?.underline}),title:l("docEditor.underline","Underline (Ctrl+U)"),children:e.jsx("u",{children:"U"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.strikethrough?"primary":"ghost",onClick:()=>O(f,{strikethrough:!C[f]?.strikethrough}),title:l("docEditor.strikethrough","Strikethrough (Ctrl+E)"),children:e.jsx("s",{children:"S"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="left"?"primary":"ghost",onClick:()=>O(f,{align:"left"}),title:l("docEditor.alignLeft","Left"),ariaLabel:l("docEditor.alignLeft","Left"),children:e.jsx(r.NiceIcon,{name:"align-left",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="center"?"primary":"ghost",onClick:()=>O(f,{align:"center"}),title:l("docEditor.alignCenter","Center"),ariaLabel:l("docEditor.alignCenter","Center"),children:e.jsx(r.NiceIcon,{name:"align-center",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.align==="right"?"primary":"ghost",onClick:()=>O(f,{align:"right"}),title:l("docEditor.alignRight","Right"),ariaLabel:l("docEditor.alignRight","Right"),children:e.jsx(r.NiceIcon,{name:"align-right",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(f,{indent:Math.min((C[f]?.indent??0)+1,4)}),title:l("docEditor.indent","Indent (Tab)"),ariaLabel:l("docEditor.indent","Indent (Tab)"),children:e.jsx(r.NiceIcon,{name:"indent",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>O(f,{indent:Math.max((C[f]?.indent??0)-1,0)}),title:l("docEditor.outdent","Outdent (Shift+Tab)"),ariaLabel:l("docEditor.outdent","Outdent (Shift+Tab)"),children:e.jsx(r.NiceIcon,{name:"outdent",size:"sm"})}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Pt.NiceColorPicker,{size:"sm",label:"",value:C[f]?.color??"var(--nice-text-primary, #000000)",onChange:u=>O(f,{color:u}),title:l("docEditor.textColor","Text color")}),e.jsx(Pt.NiceColorPicker,{size:"sm",label:"",value:C[f]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:u=>O(f,{bgColor:u}),title:l("docEditor.blockBackground","Block background")}),e.jsx("span",{className:"nice-doc-editor__sep"}),e.jsx(Ie.NiceButton,{size:"sm",variant:C[f]?.locked?"primary":"ghost",onClick:()=>O(f,{locked:!C[f]?.locked}),title:l("docEditor.lock","Lock/Unlock block"),ariaLabel:l("docEditor.lock","Lock/Unlock block"),children:e.jsx(r.NiceIcon,{name:C[f]?.locked?"lock":"unlock",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>G(f),title:l("docEditor.duplicate","Duplicate (Ctrl+D)"),ariaLabel:l("docEditor.duplicate","Duplicate (Ctrl+D)"),children:e.jsx(r.NiceIcon,{name:"copy",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ne(f),title:l("docEditor.delete","Delete block"),ariaLabel:l("docEditor.delete","Delete block"),children:e.jsx(r.NiceIcon,{name:"trash",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>y(f),title:l("docEditor.addBlock","Add block"),ariaLabel:l("docEditor.addBlock","Add block"),children:e.jsx(r.NiceIcon,{name:"plus",size:"sm"})}),I&&e.jsx(Ie.NiceButton,{size:"sm",variant:j?"primary":"ghost",onClick:()=>h(u=>!u),title:l("docEditor.find","Find & Replace (Ctrl+F)"),ariaLabel:l("docEditor.find","Find & Replace (Ctrl+F)"),children:e.jsx(r.NiceIcon,{name:"search",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ee(u=>!u),title:l("docEditor.shortcuts","Keyboard shortcuts"),ariaLabel:l("docEditor.shortcuts","Keyboard shortcuts"),children:e.jsx(r.NiceIcon,{name:"keyboard",size:"sm"})}),$&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ze,children:l("docEditor.export","Export HTML")})]}),e.jsx("input",{ref:w,type:"file",accept:"image/*,video/*",style:{display:"none"},onChange:$e}),j&&e.jsxs("div",{className:"nice-doc-editor__find-bar",style:{display:"flex",gap:4,alignItems:"center",padding:"4px 8px",background:"var(--nice-bg-secondary, #f8f9fa)",borderBottom:"1px solid var(--nice-border-color, #ddd)"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:l("docEditor.findPlaceholder","Find..."),value:c,onChange:p,style:{flex:1,maxWidth:200}}),e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:l("docEditor.replacePlaceholder","Replace..."),value:E,onChange:N,style:{flex:1,maxWidth:200}}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ge,title:l("docEditor.findPrev","Previous"),ariaLabel:l("docEditor.findPrev","Previous"),children:e.jsx(r.NiceIcon,{name:"chevron-up",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ve,title:l("docEditor.findNext","Next"),ariaLabel:l("docEditor.findNext","Next"),children:e.jsx(r.NiceIcon,{name:"chevron-down",size:"sm"})}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:We,title:l("docEditor.replaceOne","Replace"),disabled:o,children:l("docEditor.replace","Replace")}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:Ee,title:l("docEditor.replaceAll","Replace all"),disabled:o,children:l("docEditor.replaceAllBtn","All")}),e.jsx("span",{style:{fontSize:"0.75em",color:"var(--nice-text-muted, #666)"},children:m.length>0?`${z+1}/${m.length}`:"0/0"}),e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>h(!1),title:l("docEditor.closeFind","Close"),ariaLabel:l("docEditor.closeFind","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:"sm"})})]}),v&&e.jsx("div",{role:"presentation",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:()=>ee(!1),children:e.jsxs("div",{role:"presentation",style:{background:"var(--nice-bg-primary, #fff)",borderRadius:8,padding:24,maxWidth:420,width:"90%",boxShadow:"0 8px 32px var(--nice-overlay-20, rgba(0, 0, 0, 0.2))"},onClick:u=>u.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px"},children:l("docEditor.shortcutsTitle","Keyboard Shortcuts")}),e.jsx("table",{style:{width:"100%",fontSize:"0.875em",borderCollapse:"collapse"},children:e.jsx("tbody",{children:[["Ctrl+B",l("docEditor.bold","Bold")],["Ctrl+I",l("docEditor.italic","Italic")],["Ctrl+U",l("docEditor.underline","Underline")],["Ctrl+E",l("docEditor.strikethrough","Strikethrough")],["Ctrl+D",l("docEditor.duplicate","Duplicate block")],["Ctrl+Z",l("docEditor.undo","Undo")],["Ctrl+Y",l("docEditor.redo","Redo")],["Ctrl+F",l("docEditor.find","Find & Replace")],["Enter",l("docEditor.newBlock","New block")],["Backspace",l("docEditor.deleteEmpty","Delete empty block")],["Alt+↑",l("docEditor.moveUp","Move block up")],["Alt+↓",l("docEditor.moveDown","Move block down")],["Tab",l("docEditor.indent","Indent")],["Shift+Tab",l("docEditor.outdent","Outdent")],["Esc, Tab",l("docEditor.leaveEditor","Leave the editor")],["/",l("docEditor.slashCmd","Slash commands")]].map(([u,V])=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--nice-border-color, #eee)"},children:[e.jsx("td",{style:{padding:"4px 8px",fontFamily:"monospace",fontWeight:600},children:u}),e.jsx("td",{style:{padding:"4px 8px"},children:V})]},u))})}),e.jsx("div",{style:{textAlign:"right",marginTop:12},children:e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>ee(!1),children:l("docEditor.close","Close")})})]})}),e.jsxs("div",{style:{display:"flex",gap:0},children:[B&&Je.length>0&&e.jsxs("nav",{className:"nice-doc-editor__toc",style:{width:200,minWidth:160,borderRight:"1px solid var(--nice-border-color, #eee)",padding:"8px 4px",fontSize:"0.8em",overflowY:"auto",maxHeight:500},children:[e.jsx("div",{style:{fontWeight:600,padding:"4px 8px",fontSize:"0.75em",textTransform:"uppercase",color:"var(--nice-text-muted, #999)"},children:l("docEditor.toc","Contents")}),Je.map(u=>e.jsx("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"3px 8px",paddingLeft:8+(u.level-1)*12,cursor:"pointer",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",background:u.idx===f?"var(--nice-primary-bg, #e8f0fe)":void 0},onClick:()=>S(u.idx),title:u.text,children:u.text||l("docEditor.untitled","Untitled")},u.idx))]}),e.jsxs("div",{className:"nice-doc-editor__body",style:{flex:1},children:[!o&&e.jsx("span",{id:Y,className:"nice-sr-only",children:l("input.tabEscapeHint","Tab indents. To leave the editor, press Escape, then Tab.")}),C.map((u,V)=>e.jsxs("div",{role:"presentation",className:`nice-doc-editor__block nice-doc-editor__block--${u.type} ${V===f?"nice-doc-editor__block--focused":""} ${fe===V?"nice-doc-editor__block--drop-target":""} ${u.locked?"nice-doc-editor__block--locked":""}`,onClick:()=>S(V),onContextMenu:L=>at(L,V),draggable:!o&&!u.locked,onDragStart:L=>Me(L,V),onDragOver:L=>ze(L,V),onDrop:L=>qe(L,V),onDragEnd:()=>{re(null),H(null)},style:{opacity:we===V?.4:1,marginLeft:(u.indent??0)*24},children:[!o&&!u.locked&&e.jsx("div",{className:"nice-doc-editor__block-handle",title:l("docEditor.drag","Drag to reorder"),children:e.jsx(r.NiceIcon,{name:"grip",size:"sm"})}),u.locked&&e.jsx("span",{className:"nice-doc-editor__lock-icon",style:{position:"absolute",top:2,right:4,fontSize:"0.7em",opacity:.5},children:e.jsx(r.NiceIcon,{name:"lock",size:"sm"})}),u.type==="divider"?e.jsx("hr",{className:"nice-doc-editor__divider"}):u.type==="pageBreak"?e.jsxs("div",{className:"nice-doc-editor__page-break",style:{borderTop:"2px dashed var(--nice-border, #ccc)",textAlign:"center",padding:4,fontSize:"0.75em",color:"var(--nice-text-muted, #999)"},children:["— ",l("docEditor.pageBreak","Page Break")," —"]}):u.type==="image"||u.type==="video"?e.jsx("div",{className:"nice-doc-editor__media-block",children:u.src?u.type==="image"?e.jsx("img",{src:u.src,alt:u.alt??"",className:"nice-doc-editor__image",style:{maxWidth:"100%"}}):e.jsx("video",{src:u.src,controls:!0,className:"nice-doc-editor__video",style:{maxWidth:"100%"}}):!o&&e.jsxs("div",{style:{display:"flex",gap:4,alignItems:"center"},children:[e.jsx(Fe.NiceTextInput,{size:"sm",placeholder:u.type==="image"?l("docEditor.imageUrl","Image URL"):l("docEditor.videoUrl","Video URL"),value:u.src??"",onChange:L=>O(V,{src:L})}),P&&e.jsx(Ie.NiceButton,{size:"sm",variant:"ghost",onClick:()=>{S(V),w.current?.click()},title:l("docEditor.upload","Upload file"),ariaLabel:l("docEditor.upload","Upload file"),children:e.jsx(r.NiceIcon,{name:"upload",size:"sm"})})]})}):u.type==="callout"?e.jsxs("div",{className:"nice-doc-editor__callout",style:{display:"flex",gap:8,padding:"8px 12px",background:u.bgColor??"var(--nice-info-bg, #f0f7ff)",borderRadius:4,color:u.color},children:[e.jsx("span",{style:{fontSize:"1.2em",display:"inline-flex"},children:u.icon??e.jsx(r.NiceIcon,{name:"info",size:"sm"})}),e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),"data-placeholder":l("docEditor.calloutPlaceholder","Callout text..."),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{flex:1,outline:"none"},children:D(u.id,lt(u))})]}):u.type==="toggle"?e.jsxs("details",{open:u.open,className:"nice-doc-editor__toggle",onToggle:L=>O(V,{open:L.target.open}),children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:500},children:u.content.split(`
|
|
19
|
+
`)[0]||l("docEditor.toggleTitle","Toggle")}),e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{padding:"4px 0"},children:D(u.id,lt(u))})]}):u.type==="code"?e.jsxs("div",{className:"nice-doc-editor__code-block",style:{position:"relative"},children:[!o&&e.jsx(Fe.NiceTextInput,{size:"sm",value:u.language??"",onChange:L=>O(V,{language:L}),placeholder:l("docEditor.language","Language"),style:{position:"absolute",top:4,right:4,width:80,opacity:.7}}),e.jsx("pre",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,style:{fontFamily:"monospace",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-secondary, #d4d4d4)",padding:12,borderRadius:4,overflow:"auto"},children:D(u.id,lt(u))})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{ref:L=>{L&&K.current.set(u.id,L)},className:"nice-doc-editor__content",contentEditable:!o&&!u.locked,suppressContentEditableWarning:!0,style:{textAlign:u.align,fontWeight:u.bold?"bold":void 0,fontStyle:u.italic?"italic":void 0,textDecoration:[u.underline?"underline":"",u.strikethrough?"line-through":""].filter(Boolean).join(" ")||void 0,color:u.color,backgroundColor:u.bgColor},onInput:L=>Te(L,V),onFocus:()=>S(V),onKeyDown:L=>Se(L,V),"data-placeholder":!u.content&&x?x:void 0,role:"textbox","aria-multiline":"true","aria-describedby":o?void 0:Y,children:D(u.id,lt(u))}),he&&V===f&&te.length>0&&e.jsx("ul",{className:"nice-doc-editor__slash-menu",style:{position:"absolute",left:0,top:"100%",zIndex:100,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",listStyle:"none",margin:0,padding:4,minWidth:180,maxHeight:240,overflow:"auto"},children:te.map((L,ke)=>e.jsxs("li",{role:"presentation",className:ke===ve?"nice-doc-editor__slash-item--active":"",style:{padding:"6px 10px",cursor:"pointer",borderRadius:4,display:"flex",gap:8,alignItems:"center",background:ke===ve?"var(--nice-primary-bg, #e8f0fe)":void 0},onMouseDown:Ce=>{Ce.preventDefault(),xe(L)},onMouseEnter:()=>_e(ke),children:[e.jsx("span",{style:{width:24,display:"inline-flex",justifyContent:"center"},children:e.jsx(r.NiceIcon,{name:L.icon,size:"sm"})}),e.jsx("span",{children:L.label})]},`${L.type}-${L.label}`))})]})]},u.id))]})]}),Ae&&e.jsxs("div",{className:"nice-doc-editor__ctx-menu",style:{position:"fixed",left:Ae.x,top:Ae.y,zIndex:1e3,background:"var(--nice-bg-primary, #fff)",border:"1px solid var(--nice-border-color, #ddd)",borderRadius:6,boxShadow:"0 4px 16px var(--nice-overlay-12, rgba(0, 0, 0, 0.12))",padding:4,minWidth:160},children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{G(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"copy",size:"sm"})," ",l("docEditor.duplicate2","Duplicate")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{y(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"plus",size:"sm"})," ",l("docEditor.insertBelow","Insert below")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{le(Ae.idx,-1),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-up",size:"sm"})," ",l("docEditor.moveUp2","Move up")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{le(Ae.idx,1),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"arrow-down",size:"sm"})," ",l("docEditor.moveDown2","Move down")]}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer"},onClick:()=>{O(Ae.idx,{locked:!C[Ae.idx]?.locked}),Oe(null)},children:[e.jsx(r.NiceIcon,{name:C[Ae.idx]?.locked?"unlock":"lock",size:"sm"})," ",C[Ae.idx]?.locked?l("docEditor.unlock","Unlock"):l("docEditor.lock2","Lock")]}),e.jsx("hr",{style:{margin:"2px 0",border:"none",borderTop:"1px solid var(--nice-border-color, #eee)"}}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,style:{padding:"6px 12px",cursor:"pointer",color:"var(--nice-danger-dark, #d32f2f)"},onClick:()=>{ne(Ae.idx),Oe(null)},children:[e.jsx(r.NiceIcon,{name:"trash",size:"sm"})," ",l("docEditor.delete2","Delete")]})]}),J&&Le&&e.jsxs("div",{className:"nice-doc-editor__footer",style:{padding:"4px 12px",fontSize:"0.75em",color:"var(--nice-text-muted, #666)",borderTop:"1px solid var(--nice-border-color, #eee)",display:"flex",gap:16},children:[e.jsxs("span",{children:[Le.words," ",l("docEditor.words","words")]}),e.jsxs("span",{children:[Le.chars," ",l("docEditor.chars","characters")]}),e.jsxs("span",{children:[C.length," ",l("docEditor.blocks","blocks")]}),e.jsxs("span",{children:["~",Le.readingTime," ",l("docEditor.readingTime","min read")]})]})]})}),{displayName:"NiceDocumentEditor"}),_i=[];function _n(t,i){for(const o of t){if(o.id===i)return[o];const a=o.children?_n(o.children,i):[];if(a.length>0)return[o,...a]}return[]}function kn(t,i){const o=i.trim().toLowerCase();if(!o)return t;const a=[];for(const s of t){const g=s.children?kn(s.children,o):[];(s.title.toLowerCase().includes(o)||(s.content??"").toLowerCase().includes(o)||g.length>0)&&a.push({...s,children:g})}return a}const ki=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,disabled:a,readOnly:s,size:g="md",id:x,className:$,style:P,accessMode:M,pages:W=_i,selectedPageId:J,defaultSelectedPageId:B,content:I,contentFormat:q="html",editing:se,defaultEditing:oe,onPageSelect:ce,onContentChange:Z,onSave:F,onCreatePage:k,onDeletePage:l,onEditToggle:T,onVersionHistory:Y,sidebarWidth:A=260,sidebarCollapsed:_=!1,onSidebarToggle:b,searchable:C=!0,onSearch:f},S)=>{const K=r.useNiceAccessMode(M,x),w=K==="hidden";K==="disabled"&&(a=!0),K==="readOnly"&&(s=!0);const{t:d}=r.useNiceTranslation(),D=r.useControlId(x),[j,h]=n.useState(""),[c,p]=n.useState(""),[E,N]=n.useState(!1),[m,R]=r.useControllableState({value:J,defaultValue:B,fallbackValue:W[0]?.id,componentName:"NiceWiki"}),[z,ie]=r.useControllableState({value:se,defaultValue:oe,fallbackValue:!1,onChange:T,componentName:"NiceWiki"}),v=I!==void 0,[ee,U]=n.useState({}),[me,pe]=n.useState(null),ye=n.useMemo(()=>_n(W,m),[W,m]),ue=ye[ye.length-1],he=n.useMemo(()=>kn(W,j),[W,j]),de=v?I??"":ue?ee[String(ue.id)]??ue.content??"":"",ge=v?de:me??de,ae=n.useCallback(O=>{pe(null),R(O.id),ce?.(O)},[ce,R]),ve=O=>{v||pe(O),Z?.(O)},_e=()=>{pe(null),ie(!0)},te=()=>{pe(null),ie(!1)},we=()=>{ue&&(v||(U(O=>({...O,[String(ue.id)]:ge})),pe(null)),F?.(ue.id,ge),ie(!1))},re=n.useCallback(O=>{h(O),f?.(O)},[f]),fe=n.useCallback(()=>{c.trim()&&(k?.(m??null,c.trim()),p(""),N(!1))},[c,m,k]),H=n.useRef(null);r.useTreeFocus(H,{rowSelector:".nice-wiki__tree-node",onToggle:()=>{}});const X=(O,y=0)=>e.jsx("ul",{className:"nice-wiki__tree",role:y>0?"group":"none",style:{paddingLeft:y>0?16:0},children:O.map(G=>e.jsxs("li",{className:"nice-wiki__tree-item",role:"treeitem","aria-label":G.title,"aria-selected":G.id===m,children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-wiki__tree-node${G.id===m?" nice-wiki__tree-node--active":""}${G.isDraft?" nice-wiki__tree-node--draft":""}`,onClick:()=>ae(G),children:[e.jsx("span",{className:"nice-wiki__tree-icon",children:e.jsx(r.NiceIcon,{name:G.children?.length?"folder":"file",size:14})}),e.jsx("span",{className:"nice-wiki__tree-title",children:G.title}),G.isDraft&&e.jsx("span",{className:"nice-wiki__tree-draft",children:d("draft","Draft")})]}),G.children&&G.children.length>0&&X(G.children,y+1)]},G.id))});return w?null:e.jsxs("div",{ref:S,id:D,className:`nice-wiki nice-size-${g}${$?` ${$}`:""}${a?" nice-disabled":""}`,style:P,children:[!_&&e.jsxs("aside",{className:"nice-wiki__sidebar",style:{width:A},children:[e.jsxs("div",{className:"nice-wiki__sidebar-header",children:[e.jsx("span",{className:"nice-wiki__sidebar-title",children:t??d("wiki","Wiki")}),b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-toggle",onClick:()=>b(!0),"aria-label":d("collapseSidebar","Collapse sidebar"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})})]}),C&&e.jsx("input",{type:"text",className:"nice-input nice-wiki__search",value:j,onChange:O=>re(O.target.value),placeholder:d("searchPages","Search pages…"),disabled:a}),e.jsx("div",{ref:H,className:"nice-wiki__page-tree",role:"tree","aria-label":t??d("wiki","Wiki"),children:X(he)}),k&&!s&&e.jsx("div",{className:"nice-wiki__sidebar-footer",children:E?e.jsxs("div",{className:"nice-wiki__create-form",children:[e.jsx("input",{type:"text",className:"nice-input",value:c,onChange:O=>p(O.target.value),placeholder:d("pageTitle","Page title"),onKeyDown:O=>O.key==="Enter"&&fe(),disabled:a}),e.jsx("button",{type:"button",disabled:a||!c.trim(),onClick:fe,"aria-label":d("create","Create"),children:e.jsx(r.NiceIcon,{name:"check",size:14})}),e.jsx("button",{type:"button",onClick:()=>N(!1),"aria-label":d("cancel","Cancel"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}):e.jsxs("button",{type:"button",className:"nice-wiki__add-page",onClick:()=>N(!0),disabled:a,children:[e.jsx(r.NiceIcon,{name:"plus",size:14})," ",d("newPage","New page")]})})]}),_&&b&&e.jsx("button",{type:"button",className:"nice-wiki__sidebar-expand",onClick:()=>b(!1),"aria-label":d("expandSidebar","Expand sidebar"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:16})}),e.jsx("main",{className:"nice-wiki__content",children:ue?e.jsxs(e.Fragment,{children:[ye.length>1&&e.jsx("nav",{className:"nice-wiki__breadcrumbs","aria-label":t??d("wiki","Wiki"),children:ye.map((O,y)=>y<ye.length-1?e.jsxs(n.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-wiki__breadcrumb",onClick:()=>ae(O),children:O.title}),e.jsx(r.NiceIcon,{name:"chevron-right",size:12})]},O.id):e.jsx("span",{className:"nice-wiki__breadcrumb","aria-current":"page",children:O.title},O.id))}),e.jsxs("div",{className:"nice-wiki__content-header",children:[e.jsx("h1",{className:"nice-wiki__page-title",children:ue.title}),e.jsxs("div",{className:"nice-wiki__content-actions",children:[!s&&(z?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"nice-btn nice-btn--primary",disabled:a,onClick:we,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",d("save","Save")]}),e.jsx("button",{type:"button",disabled:a,onClick:te,children:d("cancel","Cancel")})]}):e.jsxs("button",{type:"button",disabled:a,onClick:_e,children:[e.jsx(r.NiceIcon,{name:"edit",size:14})," ",d("edit","Edit")]})),Y&&e.jsx("button",{type:"button",disabled:a,onClick:()=>Y(ue.id),children:d("history","History")}),l&&!s&&e.jsx("button",{type:"button",className:"nice-btn--danger",disabled:a,onClick:()=>l(ue.id),children:d("delete","Delete")})]})]}),ue.updatedAt&&e.jsxs("div",{className:"nice-wiki__page-meta",children:[ue.updatedBy&&e.jsxs("span",{children:[d("lastEditedBy","Last edited by")," ",ue.updatedBy]}),e.jsx("span",{children:new Date(ue.updatedAt).toLocaleDateString()})]}),z&&!s?e.jsx("div",{className:"nice-wiki__editor",children:q==="markdown"?e.jsx(vn,{value:ge,onChange:ve,preview:"side",minHeight:320,disabled:a}):e.jsx(sn.NiceHtmlEditor,{value:ge,onChange:ve,height:320,disabled:a})}):e.jsx("div",{className:"nice-wiki__viewer",children:e.jsx("div",{className:"nice-wiki__html","data-format":q,dangerouslySetInnerHTML:{__html:r.sanitizeHtml(q==="html"?de:jn(de))}})})]}):e.jsx("div",{className:"nice-wiki__empty",children:e.jsx("p",{children:d("selectPage","Select a page from the sidebar or create a new one.")})})}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceWiki"}),wi=n.forwardRef(function(i,o){const{enableAI:a=!0,aiModel:s,enableInlineCompletion:g=!0,completionDelay:x=500,enableExplain:$=!0,enableRefactor:P=!0,enableGenerate:M=!0,systemPrompt:W,onExplain:J,onRefactor:B,showAIToolbar:I=!0,aiShortcutKey:q="Ctrl",language:se="plaintext",value:oe,onChange:ce,onCursorPositionChange:Z,...F}=i,k=n.useRef(null),[l,T]=n.useState(null),[Y,A]=n.useState(!1),[_,b]=n.useState(""),[C,f]=n.useState(!1),[S,K]=n.useState(""),[w,d]=n.useState(""),[D,j]=n.useState(""),h=n.useRef(void 0),{t:c}=an.useNiceTranslation(),p=r.useNiceAI(),{complete:E,explain:N,refactor:m,generateFromComment:R,isLoading:z}=r.useCodeCompletion({language:se,model:s}),ie=a&&p.isConfigured,v=n.useCallback(async()=>{if(!ie||!g||!k.current||!k.current.getEditor())return;const ge=k.current.getCursorPosition(),ve=k.current.getValue().split(`
|
|
20
20
|
`),_e=ve.slice(0,ge.lineNumber-1),te=ve[ge.lineNumber-1]||"",we=[..._e,te.slice(0,ge.column-1)].join(`
|
|
21
21
|
`),re=[te.slice(ge.column-1),...ve.slice(ge.lineNumber)].join(`
|
|
22
22
|
`);try{const fe=await E(we,re);fe&&T({lineNumber:ge.lineNumber,column:ge.column,text:fe})}catch{}},[ie,g,E]),ee=n.useCallback(async()=>{if(!ie||!$||!k.current)return"";const de=k.current.getSelection();if(!de)return"";j(de),A(!0),b("");try{const ge=await N(de);return b(ge),J?.(de,ge),ge}catch{return b(c("codeEditorAI.explanationFailed","Failed to explain code")),""}},[ie,$,N,J,c]),U=n.useCallback(async de=>{if(!ie||!P||!k.current)return"";const ge=k.current.getSelection();if(!ge)return"";try{const ae=await m(ge,de);return d(ae),B?.(ge,ae),ae}catch{return""}},[ie,P,m,B]),me=n.useCallback(async()=>{if(!ie||!M||!k.current)return;const de=k.current.getCursorPosition(),ae=k.current.getValue().split(`
|
|
23
23
|
`);let ve="";for(let _e=de.lineNumber-1;_e>=0&&_e>=de.lineNumber-3;_e--){const te=ae[_e]?.trim()||"";if(te.startsWith("//")||te.startsWith("#")||te.startsWith("/*")||te.startsWith("*")){ve=te.replace(/^\/\/\s*|^#\s*|^\/\*\s*|\*\/\s*$|^\*\s*/g,"").trim();break}}if(ve)try{const _e=await R(ve);_e&&k.current&&k.current.insertText(`
|
|
24
|
-
`+_e)}catch{}},[ie,M,R]),pe=n.useCallback(()=>{!l||!k.current||(k.current.insertText(l.text),T(null))},[l]),ye=n.useCallback(()=>{T(null)},[]),ue=n.useCallback(de=>{Z?.(de),!(!ie||!g)&&(h.current&&clearTimeout(h.current),T(null),h.current=setTimeout(()=>{v()},x))},[Z,ie,g,x,v]);n.useEffect(()=>{if(!k.current?.getEditor()||!ie)return;const ge=ae=>{if(
|
|
24
|
+
`+_e)}catch{}},[ie,M,R]),pe=n.useCallback(()=>{!l||!k.current||(k.current.insertText(l.text),T(null))},[l]),ye=n.useCallback(()=>{T(null)},[]),ue=n.useCallback(de=>{Z?.(de),!(!ie||!g)&&(h.current&&clearTimeout(h.current),T(null),h.current=setTimeout(()=>{v()},x))},[Z,ie,g,x,v]);n.useEffect(()=>{if(!k.current?.getEditor()||!ie)return;const ge=ae=>{if(q==="Ctrl"&&ae.ctrlKey||q==="Alt"&&ae.altKey||q==="Meta"&&ae.metaKey){if(ae.key===" "&&g&&(ae.preventDefault(),v()),ae.key==="e"&&$&&(ae.preventDefault(),ee()),ae.key==="r"&&P){ae.preventDefault();const _e=k.current?.getSelection();_e&&(j(_e),f(!0))}ae.key==="g"&&M&&(ae.preventDefault(),me())}ae.key==="Tab"&&l&&(ae.preventDefault(),pe()),ae.key==="Escape"&&l&&ye()};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[ie,q,g,$,P,M,v,ee,me,l,pe,ye]),n.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const he=n.useCallback(()=>{if(!w||!k.current)return;const de=k.current.getEditor();if(de?.executeEdits&&de?.getSelection){const ge=de.getSelection();de.executeEdits("ai-refactor",[{range:ge,text:w}])}f(!1),d(""),K("")},[w]);return n.useImperativeHandle(o,()=>({...k.current,getEditor:()=>k.current?.getEditor(),getMonaco:()=>k.current?.getMonaco(),focus:()=>k.current?.focus(),getValue:()=>k.current?.getValue()||"",setValue:de=>k.current?.setValue(de),getSelection:()=>k.current?.getSelection()||"",insertText:de=>k.current?.insertText(de),formatDocument:()=>k.current?.formatDocument(),goToLine:(de,ge)=>k.current?.goToLine(de,ge),findReplace:()=>k.current?.findReplace(),undo:()=>k.current?.undo(),redo:()=>k.current?.redo(),getCursorPosition:()=>k.current?.getCursorPosition()||{lineNumber:1,column:1},setMarkers:de=>k.current?.setMarkers(de),triggerCompletion:v,explainSelection:ee,refactorSelection:U,generateFromComment:me,acceptCompletion:pe,dismissCompletion:ye})),e.jsxs("div",{className:"nice-code-editor-ai","data-testid":i["data-testid"],children:[I&&ie&&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:c("codeEditorAI.ai","AI")}),z&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:c("codeEditorAI.loading","Thinking...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__toolbar-right",children:[g&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>v(),disabled:z,title:`${c("codeEditorAI.complete","Complete")} (${q}+Space)`,children:[e.jsx(r.NiceIcon,{name:"lightbulb",size:14})," ",c("codeEditorAI.complete","Complete")]}),$&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>ee(),disabled:z,title:`${c("codeEditorAI.explain","Explain")} (${q}+E)`,children:[e.jsx(r.NiceIcon,{name:"book",size:14})," ",c("codeEditorAI.explain","Explain")]}),P&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>{const de=k.current?.getSelection();de&&(j(de),f(!0))},disabled:z,title:`${c("codeEditorAI.refactor","Refactor")} (${q}+R)`,children:[e.jsx(r.NiceIcon,{name:"settings",size:14})," ",c("codeEditorAI.refactor","Refactor")]}),M&&e.jsxs("button",{type:"button",className:"nice-code-editor-ai__toolbar-btn",onClick:()=>me(),disabled:z,title:`${c("codeEditorAI.generate","Generate")} (${q}+G)`,children:[e.jsx(r.NiceIcon,{name:"zap",size:14})," ",c("codeEditorAI.generate","Generate")]})]})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx(Et.NiceCodeEditor,{ref:k,value:oe,onChange:ce,language:se,onCursorPositionChange:ue,...F}),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.jsx("span",{className:"nice-code-editor-ai__ghost-text-hint",children:c("codeEditorAI.tab","Tab {accept}").replace("{accept}",String(c("codeEditorAI.toAccept","to accept")))})]})]}),Y&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--explain",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"book",size:16})," ",c("codeEditorAI.explanation","Explanation")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>A(!1),"aria-label":c("codeEditorAI.close","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-code-editor-ai__panel-body",children:z?e.jsx("div",{className:"nice-code-editor-ai__panel-loading",children:c("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:D}),e.jsx("div",{className:"nice-code-editor-ai__explanation-text",children:_||c("codeEditorAI.noExplanation","Select code and click Explain")})]})})]}),C&&e.jsxs("div",{className:"nice-code-editor-ai__panel nice-code-editor-ai__panel--refactor",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("h4",{children:[e.jsx(r.NiceIcon,{name:"settings",size:16})," ",c("codeEditorAI.refactorCode","Refactor Code")]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__panel-close",onClick:()=>{f(!1),d(""),K("")},"aria-label":c("codeEditorAI.close","Close"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-body",children:[e.jsx("pre",{className:"nice-code-editor-ai__code-preview",children:D}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-input",children:[e.jsx("input",{type:"text",placeholder:c("codeEditorAI.refactorInstruction",'Describe how to refactor (e.g., "extract function", "add error handling")'),value:S,onChange:de=>K(de.target.value),onKeyDown:de=>{de.key==="Enter"&&S&&U(S)}}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactor-btn",onClick:()=>U(S),disabled:z||!S,children:z?c("codeEditorAI.refactoring","Refactoring..."):c("codeEditorAI.refactor","Refactor")})]}),w&&e.jsxs("div",{className:"nice-code-editor-ai__refactor-result",children:[e.jsx("h5",{children:c("codeEditorAI.refactoredCode","Refactored Code")}),e.jsx("pre",{className:"nice-code-editor-ai__code-preview nice-code-editor-ai__code-preview--result",children:w}),e.jsxs("div",{className:"nice-code-editor-ai__refactor-actions",children:[e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-apply",onClick:he,children:[e.jsx(r.NiceIcon,{name:"check",size:14})," ",c("codeEditorAI.apply","Apply")]}),e.jsxs("button",{type:"button",className:"nice-code-editor-ai__refactor-discard",onClick:()=>{d(""),K("")},children:[e.jsx(r.NiceIcon,{name:"close",size:14})," ",c("codeEditorAI.discard","Discard")]})]})]})]})]})]})}),Ni=[];function Ci(t){const i=t instanceof Date?t:new Date(t),o=(a,s=2)=>String(a).padStart(s,"0");return`${o(i.getHours())}:${o(i.getMinutes())}:${o(i.getSeconds())}.${o(i.getMilliseconds(),3)}`}function Si(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const wn=n.forwardRef(function(i,o){const{t:a}=r.useNiceTranslation();kt.injectStyleOnce(Ei,$i);const{entries:s=Ni,maxHeight:g=240,autoScroll:x=!0,showTimestamps:$=!0,levelFilter:P,onClear:M,title:W,emptyText:J=a("logConsole.noOutput","No output"),clearLabel:B=a("logConsole.clear","Clear"),fontFamily:I,className:q,style:se,id:oe,"data-testid":ce}=i,Z=n.useRef(null),F=n.useMemo(()=>{if(!P||P.length===0)return s;const T=new Set(P);return s.filter(Y=>T.has(Y.level??"log"))},[s,P]);n.useEffect(()=>{x&&Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[F.length,x]);const k=!!W||!!M,l="nice-log-console"+(q?` ${q}`:"");return e.jsxs("div",{ref:o,id:oe,className:l,style:{...I?{fontFamily:I}:null,...se},"data-testid":ce,children:[k&&e.jsxs("div",{className:"nice-log-console__header",children:[e.jsx("span",{className:"nice-log-console__title",children:W}),M&&e.jsx("button",{type:"button",className:"nice-log-console__clear",onClick:M,"aria-label":B,children:B})]}),e.jsx("div",{ref:Z,className:"nice-log-console__body",style:{maxHeight:typeof g=="number"?`${g}px`:g},role:"log","aria-live":"polite","aria-relevant":"additions",children:F.length===0?e.jsx("div",{className:"nice-log-console__empty",children:J}):F.map((T,Y)=>{const A=T.level??"log";return e.jsxs("div",{className:`nice-log-console__entry nice-log-console__entry--${A}`,children:[$&&T.timestamp!=null&&e.jsx("span",{className:"nice-log-console__time",children:Ci(T.timestamp)}),e.jsx("span",{className:"nice-log-console__level",children:A}),T.source&&e.jsx("span",{className:"nice-log-console__source",children:T.source}),e.jsx("span",{className:"nice-log-console__message",children:T.message}),T.data!==void 0&&e.jsx("pre",{className:"nice-log-console__data",children:Si(T.data)})]},Y)})})]})}),Ei="nice-log-console-styles",$i=`
|
|
25
25
|
.nice-log-console {
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-direction: column;
|
|
@@ -117,7 +117,7 @@ ${L}`:L}:Ce);t||b(ke),i?.(ke)},[C,t,i,pe,W,he]),Me=n.useCallback((u,V)=>{re(V),u
|
|
|
117
117
|
.nice-log-console__entry--debug { color: var(--nice-text-muted, #9ca3af); }
|
|
118
118
|
.nice-log-console__entry--trace { color: var(--nice-text-disabled, #b8bfc9); }
|
|
119
119
|
.nice-log-console__entry--trace .nice-log-console__level { color: var(--nice-text-disabled, #b8bfc9); }
|
|
120
|
-
`,
|
|
120
|
+
`,Ii=[{target:".nice-script-runner",titleKey:"tutorial.scriptRunner.intro.title",title:"Script runner",contentKey:"tutorial.scriptRunner.intro.content",content:"Write a script and sample input, click Run, then inspect the result and captured logs below.",placement:"auto"}];function Wt(t){if(t===void 0)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Jt(t){const i=t.trim();if(i==="")return{value:void 0,error:null};try{return{value:JSON.parse(i),error:null}}catch(o){return{value:t,error:o instanceof Error?o.message:"Invalid JSON"}}}function Mi(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}const Ti=n.forwardRef(function(i,o){const{t:a}=r.useNiceTranslation();kt.injectStyleOnce(Ri,Ai);const{value:s,defaultValue:g,onChange:x,language:$="javascript",onRun:P,input:M,onInputChange:W,showInputPanel:J,extraLibs:B,height:I=260,running:q,autoRun:se=!1,autoRunDelay:oe=600,layout:ce="vertical",runLabel:Z=a("scriptRunner.run","Run"),theme:F="auto",tutorial:k,className:l,style:T,id:Y,"data-testid":A}=i,[_,b]=r.useControllableState({value:s,defaultValue:g,fallbackValue:"",onChange:x,componentName:"NiceScriptRunner"}),C=J??M!==void 0,[f,S]=n.useState(()=>Wt(M)),[K,w]=n.useState(null),[d,D]=n.useState(!1),[j,h]=n.useState(null),c=q??d,p=F==="light"?"vs":F==="dark"?"vs-dark":F;n.useEffect(()=>{S(Wt(M))},[M]);const E=n.useCallback(async()=>{const ie=Jt(f),v=typeof performance<"u"?performance.now():Date.now();q===void 0&&D(!0);try{const ee=await P(_,ie.value),U=ee.durationMs??Math.round((typeof performance<"u"?performance.now():Date.now())-v);h({...ee,durationMs:U})}catch(ee){h({ok:!1,error:ee instanceof Error?ee.message:String(ee),durationMs:Math.round((typeof performance<"u"?performance.now():Date.now())-v)})}finally{q===void 0&&D(!1)}},[f,P,_,q]),N=n.useRef(E);N.current=E,n.useEffect(()=>{if(!se)return;const ie=setTimeout(()=>{N.current()},oe);return()=>clearTimeout(ie)},[se,oe,_,f]);const m=n.useCallback(ie=>{S(ie);const v=Jt(ie);w(v.error),W?.(v.value)},[W]),R=typeof I=="number"?`${I}px`:I,z=`nice-script-runner nice-script-runner--${ce}`+(l?` ${l}`:"");return e.jsxs("div",{ref:o,id:Y,className:z,style:T,"data-testid":A,children:[e.jsxs("div",{className:"nice-script-runner__toolbar",children:[e.jsxs("button",{type:"button",className:"nice-script-runner__run",onClick:()=>void E(),disabled:c,children:[c?"…":e.jsx(r.NiceIcon,{name:"play",size:14})," ",Z]}),j?.durationMs!=null&&e.jsxs("span",{className:"nice-script-runner__status",children:[e.jsx("span",{className:"nice-script-runner__badge nice-script-runner__badge--"+(j.ok?"ok":"error"),children:j.ok?a("scriptRunner.ok","OK"):a("scriptRunner.failed","Failed")}),e.jsxs("span",{className:"nice-script-runner__duration",children:[j.durationMs," ms"]})]}),k&&e.jsx("span",{style:{marginLeft:"auto"},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(k,Ii)})})]}),e.jsxs("div",{className:"nice-script-runner__panes",children:[e.jsxs("div",{className:"nice-script-runner__editors",children:[e.jsx(Et.NiceCodeEditor,{value:_,onChange:b,language:$,theme:p,height:R,extraLibs:B,options:{minimap:!1}}),C&&e.jsxs("div",{className:"nice-script-runner__input",children:[e.jsxs("div",{className:"nice-script-runner__pane-label",children:[a("scriptRunner.inputJson","Input (JSON)"),K&&e.jsxs("span",{className:"nice-script-runner__input-error",children:[" — ",K]})]}),e.jsx(Et.NiceCodeEditor,{value:f,onChange:m,language:"json",theme:p,height:120,options:{minimap:!1,lineNumbers:"off"}})]})]}),e.jsxs("div",{className:"nice-script-runner__output",children:[j?.error&&e.jsx("div",{className:"nice-script-runner__error",children:j.error}),j&&j.result!==void 0&&e.jsxs("div",{className:"nice-script-runner__result",children:[e.jsx("div",{className:"nice-script-runner__pane-label",children:a("scriptRunner.result","Result")}),e.jsx("pre",{className:"nice-script-runner__result-body",children:Mi(j.result)})]}),e.jsx(wn,{title:a("scriptRunner.logs","Logs"),entries:j?.logs??[],maxHeight:160,emptyText:"Run the script to see logs"})]})]})]})}),Ri="nice-script-runner-styles",Ai=`
|
|
121
121
|
.nice-script-runner {
|
|
122
122
|
display: flex;
|
|
123
123
|
flex-direction: column;
|
|
@@ -215,7 +215,7 @@ ${L}`:L}:Ce);t||b(ke),i?.(ke)},[C,t,i,pe,W,he]),Me=n.useCallback((u,V)=>{re(V),u
|
|
|
215
215
|
font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
|
|
216
216
|
font-size: 12px;
|
|
217
217
|
}
|
|
218
|
-
`,
|
|
218
|
+
`,Di=[{target:".nice-key-value-editor",titleKey:"tutorial.keyValueEditor.intro.title",title:"Key/value editor",contentKey:"tutorial.keyValueEditor.intro.content",content:"Add key/value rows for headers, params, env vars or config; mask secret values, toggle rows on/off, and watch for duplicate keys.",placement:"auto"}],zi=n.forwardRef(function(i,o){const{t:a}=r.useNiceTranslation();kt.injectStyleOnce(Li,Pi);const{value:s,defaultValue:g,onChange:x,allowSecret:$=!1,allowToggle:P=!1,allowDescription:M=!1,keySuggestions:W,keyPlaceholder:J=a("keyValueEditor.key","Key"),valuePlaceholder:B=a("keyValueEditor.value","Value"),addLabel:I=a("keyValueEditor.add","Add"),readOnly:q=!1,duplicateKeyWarning:se=!0,tutorial:oe,className:ce,style:Z,id:F,"data-testid":k}=i,[l,T]=r.useControllableState({value:s,defaultValue:g,fallbackValue:[],onChange:x,componentName:"NiceKeyValueEditor"}),Y=n.useMemo(()=>`nice-kv-keys-${Math.random().toString(36).slice(2,9)}`,[]),A=n.useMemo(()=>{const S=new Map,K=new Set;if(se){for(const w of l){const d=w.key.trim();d!==""&&S.set(d,(S.get(d)??0)+1)}S.forEach((w,d)=>{w>1&&K.add(d)})}return K},[l,se]),_=(S,K)=>{T(l.map((w,d)=>d===S?{...w,...K}:w))},b=S=>{T(l.filter((K,w)=>w!==S))},C=()=>{T([...l,{key:"",value:"",type:"text",enabled:!0}])},f="nice-key-value-editor"+(ce?` ${ce}`:"");return e.jsxs("div",{ref:o,id:F,className:f,style:{position:"relative",...Z},"data-testid":k,children:[e.jsx("span",{style:{position:"absolute",top:0,right:0,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(oe,Di)})}),W&&W.length>0&&e.jsx("datalist",{id:Y,children:W.map(S=>e.jsx("option",{value:S},S))}),e.jsx("div",{className:"nice-key-value-editor__rows",children:l.map((S,K)=>{const w=S.type==="secret",d=S.key.trim()!==""&&A.has(S.key.trim()),D=P&&S.enabled===!1;return e.jsxs("div",{className:"nice-key-value-editor__row"+(D?" nice-key-value-editor__row--disabled":""),children:[P&&e.jsx("input",{type:"checkbox",className:"nice-key-value-editor__toggle",checked:S.enabled!==!1,onChange:j=>_(K,{enabled:j.target.checked}),disabled:q,"aria-label":a("keyValueEditor.enabled","Enabled")}),e.jsx("input",{type:"text",className:"nice-key-value-editor__key"+(d?" nice-key-value-editor__key--dup":""),value:S.key,list:W?Y:void 0,placeholder:J,onChange:j=>_(K,{key:j.target.value}),readOnly:q,"aria-label":J,title:d?a("keyValueEditor.duplicateKey","Duplicate key"):void 0}),e.jsx("input",{type:w?"password":"text",className:"nice-key-value-editor__value",value:S.value,placeholder:B,onChange:j=>_(K,{value:j.target.value}),readOnly:q,autoComplete:w?"new-password":"off","aria-label":B}),$&&e.jsx("button",{type:"button",className:"nice-key-value-editor__secret"+(w?" nice-key-value-editor__secret--on":""),onClick:()=>_(K,{type:w?"text":"secret"}),disabled:q,title:w?a("keyValueEditor.secretClickToRevealAs","Secret (click to reveal as text)"):a("keyValueEditor.markAsSecret","Mark as secret"),"aria-pressed":w,"aria-label":a("keyValueEditor.toggleSecret","Toggle secret"),children:e.jsx(r.NiceIcon,{name:"lock",size:16})}),M&&e.jsx("input",{type:"text",className:"nice-key-value-editor__desc",value:S.description??"",placeholder:a("keyValueEditor.description","Description"),onChange:j=>_(K,{description:j.target.value}),readOnly:q,"aria-label":a("keyValueEditor.description","Description")}),!q&&e.jsx("button",{type:"button",className:"nice-key-value-editor__remove",onClick:()=>b(K),title:a("keyValueEditor.removeRow","Remove row"),"aria-label":a("keyValueEditor.removeRow","Remove row"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},S.id??K)})}),!q&&e.jsxs("button",{type:"button",className:"nice-key-value-editor__add",onClick:C,children:["+ ",I]})]})}),Li="nice-key-value-editor-styles",Pi=`
|
|
219
219
|
.nice-key-value-editor {
|
|
220
220
|
display: flex;
|
|
221
221
|
flex-direction: column;
|
|
@@ -298,16 +298,16 @@ ${L}`:L}:Ce);t||b(ke),i?.(ke)},[C,t,i,pe,W,he]),Me=n.useCallback((u,V)=>{re(V),u
|
|
|
298
298
|
.nice-key-value-editor__add:hover {
|
|
299
299
|
background: var(--nice-bg-secondary, #f5f5f5);
|
|
300
300
|
}
|
|
301
|
-
`,Bi=["street","streetNumber","apartment","city","postalCode","state","country"],xt={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Hi=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B={},onChange:I,fields:X=Bi,placeholders:se={},countries:oe,layout:ce="vertical",countryFirst:Z=!1,validatePostalCode:F},k)=>{const l=r.useNiceAccessMode(J,P),T=l==="hidden";l==="disabled"&&(s=!0),l==="readOnly"&&(g=!0);const{t:Y}=r.useNiceTranslation(),A=r.useControlId(P),_=n.useCallback((S,K)=>{I?.({...B,[S]:K})},[B,I]),b=n.useMemo(()=>{if(F&&B.postalCode)return F(B.postalCode,B.country)},[F,B.postalCode,B.country]),C=n.useMemo(()=>Z&&X.includes("country")?["country",...X.filter(S=>S!=="country")]:X,[X,Z]),f=`nice-address nice-address--${ce} nice-size-${x}`;return T?null:e.jsxs("div",{ref:k,id:A,className:`${f}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,role:"group","aria-label":t??Y("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:C.map(S=>S==="country"&&oe?e.jsxs("div",{className:`nice-address__field nice-address__field--${S}`,children:[e.jsx("label",{className:"nice-address__field-label",children:Y(S,xt[S])}),e.jsxs("select",{className:"nice-input nice-select",value:B.country??"",onChange:K=>_("country",K.target.value),disabled:s,"aria-label":Y(S,xt[S]),children:[e.jsx("option",{value:"",children:se.country??Y("selectCountry","— Select country —")}),oe.map(K=>e.jsx("option",{value:K.code,children:K.name},K.code))]})]},S):e.jsxs("div",{className:`nice-address__field nice-address__field--${S}`,children:[e.jsx("label",{className:"nice-address__field-label",children:Y(S,xt[S])}),e.jsx("input",{className:`nice-input${S==="postalCode"&&b?" nice-input--error":""}`,type:"text",name:$?`${$}.${S}`:S,value:B[S]??"",onChange:K=>_(S,K.target.value),placeholder:se[S]??"",disabled:s,readOnly:g,"aria-label":Y(S,xt[S])}),S==="postalCode"&&b&&e.jsx("span",{className:"nice-error-text",children:b})]},S))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceAddressInput"}),Fi=[],Ki={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)"},Ui=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B,onChange:I,accounts:X=Fi,treeView:se=!1,placeholder:oe,searchable:ce=!0,showType:Z=!0,onSearch:F},k)=>{const l=r.useNiceAccessMode(J,P),T=l==="hidden";l==="disabled"&&(s=!0),l==="readOnly"&&(g=!0);const{t:Y}=r.useNiceTranslation(),A=r.useControlId(P),[_,b]=n.useState(""),[C,f]=n.useState(!1),S=n.useMemo(()=>{const m=R=>{for(const z of R){if(z.code===B)return z;if(z.children){const ie=m(z.children);if(ie)return ie}}};return m(X)},[X,B]),K=n.useMemo(()=>{const m=[],R=z=>{for(const ie of z)m.push(ie),ie.children&&R(ie.children)};return R(X),m},[X]),w=n.useMemo(()=>{if(!_)return K;const m=_.toLowerCase();return K.filter(R=>R.code.toLowerCase().includes(m)||R.name.toLowerCase().includes(m))},[K,_]),d=n.useCallback(m=>{b(m),F?.(m),f(!0)},[F]),D=n.useCallback(m=>{I?.(m.code,m),f(!1),b("")},[I]),j=n.useRef(null),h=C&&w.length>0,{activeIndex:c,setActiveIndex:p,handleKeyDown:E}=ht.useListKeyboardNav(w,{open:h,onSelect:m=>D(m),onClose:()=>f(!1),onOpen:()=>{p(0),f(!0)},intentRef:j}),N=`${A}-accounts`;return T?null:e.jsxs("div",{ref:k,id:A,className:`nice-account-picker nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${A}-input`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:ce&&!g?e.jsx("input",{ref:j,id:`${A}-input`,className:"nice-input",type:"text",value:C?_:S?`${S.code} — ${S.name}`:"",onChange:m=>{d(m.target.value),p(0)},onFocus:()=>{b(""),p(-1),f(!0)},onBlur:()=>setTimeout(()=>f(!1),200),onKeyDown:E,placeholder:oe??Y("searchAccount","Search account…"),disabled:s,required:a,autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":h,"aria-controls":h?N:void 0,"aria-activedescendant":h&&w[c]?`${N}-${c}`:void 0}):e.jsx("div",{className:"nice-account-picker__display",children:S?`${S.code} — ${S.name}`:oe??Y("selectAccount","Select account…")})}),h&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",id:N,children:w.map((m,R)=>e.jsxs("div",{id:`${N}-${R}`,className:`nice-account-picker__option${m.code===B?" nice-account-picker__option--selected":""}${R===c?" nice-account-picker__option--active":""}${m.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":m.code===B,onMouseEnter:()=>p(R),onClick:()=>D(m),children:[Z&&m.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Ki[m.type]},title:m.type,children:e.jsx(r.NiceIcon,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:m.code}),e.jsx("span",{className:"nice-account-picker__name",children:m.name})]},m.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceAccountPicker"}),Yi=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B=[],onChange:I,contacts:X=[],onSearch:se,searchDelay:oe=300,multiple:ce=!1,placeholder:Z,onContactClick:F,maxSelections:k},l)=>{const T=r.useNiceAccessMode(J,P),Y=T==="hidden";T==="disabled"&&(s=!0),T==="readOnly"&&(g=!0);const{t:A}=r.useNiceTranslation(),_=r.useControlId(P),[b,C]=n.useState(""),[f,S]=n.useState([]),[K,w]=n.useState(!1),[d,D]=n.useState(!1),j=n.useMemo(()=>{const v=[...X,...f],ee=new Map(v.map(U=>[U.id,U]));return B.map(U=>ee.get(U)).filter(Boolean)},[B,X,f]),h=n.useCallback(v=>{if(C(v),v.length<1){S([]),w(!1);return}if(se){D(!0);const me=setTimeout(async()=>{const pe=await se(v);S(pe),w(!0),D(!1)},oe);return()=>clearTimeout(me)}const ee=v.toLowerCase(),U=X.filter(me=>me.name.toLowerCase().includes(ee)||me.email?.toLowerCase().includes(ee)||me.phone?.includes(v));S(U),w(!0)},[se,X,oe]),c=n.useCallback(v=>{if(ce)if(B.includes(v.id))I?.(B.filter(ee=>ee!==v.id));else{if(k&&B.length>=k)return;I?.([...B,v.id])}else I?.([v.id]),w(!1),C("")},[B,I,ce,k]),p=n.useCallback(v=>{I?.(B.filter(ee=>ee!==v))},[B,I]),E=n.useRef(null),N=K&&f.length>0,{activeIndex:m,setActiveIndex:R,handleKeyDown:z}=ht.useListKeyboardNav(f,{open:N,onSelect:v=>c(v),onClose:()=>w(!1),onOpen:()=>{f.length>0&&(R(0),w(!0))},intentRef:E}),ie=`${_}-results`;return Y?null:e.jsxs("div",{ref:l,id:_,className:`nice-contact-picker nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),j.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:j.map(v=>e.jsxs("span",{role:F?"button":void 0,tabIndex:F?0:void 0,onKeyDown:F?r.clickOnActivationKey:void 0,className:"nice-contact-picker__chip",onClick:()=>F?.(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:v.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:ee=>{ee.stopPropagation(),p(v.id)},disabled:s,"aria-label":A("controls.remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},v.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{ref:E,className:"nice-input",type:"text",value:b,onChange:v=>{h(v.target.value),R(0)},onFocus:()=>b.length>0&&w(!0),onBlur:()=>setTimeout(()=>w(!1),200),onKeyDown:z,placeholder:Z??A("searchContacts","Search contacts…"),disabled:s,"aria-label":A("contactPicker.search","Search contacts"),autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":N,"aria-controls":N?ie:void 0,"aria-activedescendant":N&&f[m]?`${ie}-${m}`:void 0}),d&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]}),N&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",id:ie,"aria-multiselectable":ce||void 0,children:f.map((v,ee)=>e.jsxs("div",{id:`${ie}-${ee}`,className:`nice-contact-picker__option${B.includes(v.id)?" nice-contact-picker__option--selected":""}${ee===m?" nice-contact-picker__option--active":""}`,role:"option","aria-selected":B.includes(v.id),onMouseEnter:()=>R(ee),onClick:()=>c(v),children:[v.avatarUrl&&e.jsx("img",{src:v.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:v.name}),v.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:v.subtitle}),v.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:v.email})]}),v.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(r.NiceIcon,{name:v.type==="person"?"user":"building",size:16})})]},v.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceContactPicker"}),qi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Qt={recent:"Recently Used",smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",travel:"Travel & Places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"},Et=["","🏻","🏼","🏽","🏾","🏿"],_t=[{emoji:"😀",name:"grinning face",category:"smileys",keywords:["happy","smile"]},{emoji:"😃",name:"grinning face with big eyes",category:"smileys"},{emoji:"😄",name:"grinning face with smiling eyes",category:"smileys"},{emoji:"😁",name:"beaming face",category:"smileys"},{emoji:"😅",name:"grinning face with sweat",category:"smileys"},{emoji:"🤣",name:"rolling on the floor laughing",category:"smileys",keywords:["rofl"]},{emoji:"😂",name:"face with tears of joy",category:"smileys",keywords:["lol","laugh"]},{emoji:"🙂",name:"slightly smiling face",category:"smileys"},{emoji:"😉",name:"winking face",category:"smileys",keywords:["wink"]},{emoji:"😊",name:"smiling face with smiling eyes",category:"smileys"},{emoji:"😇",name:"smiling face with halo",category:"smileys",keywords:["angel"]},{emoji:"🥰",name:"smiling face with hearts",category:"smileys",keywords:["love"]},{emoji:"😍",name:"smiling face with heart-eyes",category:"smileys"},{emoji:"🤩",name:"star-struck",category:"smileys",keywords:["wow"]},{emoji:"😘",name:"face blowing a kiss",category:"smileys",keywords:["kiss"]},{emoji:"😗",name:"kissing face",category:"smileys"},{emoji:"😚",name:"kissing face with closed eyes",category:"smileys"},{emoji:"😋",name:"face savoring food",category:"smileys",keywords:["yum"]},{emoji:"😛",name:"face with tongue",category:"smileys"},{emoji:"😜",name:"winking face with tongue",category:"smileys"},{emoji:"🤪",name:"zany face",category:"smileys",keywords:["crazy"]},{emoji:"😝",name:"squinting face with tongue",category:"smileys"},{emoji:"🤑",name:"money-mouth face",category:"smileys"},{emoji:"🤗",name:"hugging face",category:"smileys",keywords:["hug"]},{emoji:"🤭",name:"face with hand over mouth",category:"smileys"},{emoji:"🤫",name:"shushing face",category:"smileys",keywords:["quiet"]},{emoji:"🤔",name:"thinking face",category:"smileys",keywords:["think","hmm"]},{emoji:"🤐",name:"zipper-mouth face",category:"smileys"},{emoji:"🤨",name:"face with raised eyebrow",category:"smileys"},{emoji:"😐",name:"neutral face",category:"smileys"},{emoji:"😑",name:"expressionless face",category:"smileys"},{emoji:"😶",name:"face without mouth",category:"smileys"},{emoji:"😏",name:"smirking face",category:"smileys",keywords:["smirk"]},{emoji:"😒",name:"unamused face",category:"smileys"},{emoji:"🙄",name:"face with rolling eyes",category:"smileys"},{emoji:"😬",name:"grimacing face",category:"smileys"},{emoji:"😮💨",name:"face exhaling",category:"smileys"},{emoji:"🤥",name:"lying face",category:"smileys"},{emoji:"😌",name:"relieved face",category:"smileys"},{emoji:"😔",name:"pensive face",category:"smileys",keywords:["sad"]},{emoji:"😪",name:"sleepy face",category:"smileys"},{emoji:"🤤",name:"drooling face",category:"smileys"},{emoji:"😴",name:"sleeping face",category:"smileys",keywords:["sleep","zzz"]},{emoji:"😷",name:"face with medical mask",category:"smileys",keywords:["sick"]},{emoji:"🤒",name:"face with thermometer",category:"smileys"},{emoji:"🤕",name:"face with head-bandage",category:"smileys"},{emoji:"🤢",name:"nauseated face",category:"smileys"},{emoji:"🤮",name:"face vomiting",category:"smileys"},{emoji:"🤧",name:"sneezing face",category:"smileys"},{emoji:"🥵",name:"hot face",category:"smileys"},{emoji:"🥶",name:"cold face",category:"smileys"},{emoji:"🥴",name:"woozy face",category:"smileys",keywords:["drunk"]},{emoji:"😵",name:"face with crossed-out eyes",category:"smileys"},{emoji:"🤯",name:"exploding head",category:"smileys",keywords:["mind blown"]},{emoji:"🤠",name:"cowboy hat face",category:"smileys"},{emoji:"🥳",name:"partying face",category:"smileys",keywords:["party"]},{emoji:"🥸",name:"disguised face",category:"smileys"},{emoji:"😎",name:"smiling face with sunglasses",category:"smileys",keywords:["cool"]},{emoji:"🤓",name:"nerd face",category:"smileys",keywords:["nerd"]},{emoji:"🧐",name:"face with monocle",category:"smileys"},{emoji:"😕",name:"confused face",category:"smileys"},{emoji:"😟",name:"worried face",category:"smileys"},{emoji:"🙁",name:"slightly frowning face",category:"smileys"},{emoji:"☹️",name:"frowning face",category:"smileys"},{emoji:"😮",name:"face with open mouth",category:"smileys",keywords:["surprised"]},{emoji:"😯",name:"hushed face",category:"smileys"},{emoji:"😲",name:"astonished face",category:"smileys"},{emoji:"😳",name:"flushed face",category:"smileys"},{emoji:"🥺",name:"pleading face",category:"smileys"},{emoji:"😦",name:"frowning face with open mouth",category:"smileys"},{emoji:"😧",name:"anguished face",category:"smileys"},{emoji:"😨",name:"fearful face",category:"smileys"},{emoji:"😰",name:"anxious face with sweat",category:"smileys"},{emoji:"😥",name:"sad but relieved face",category:"smileys"},{emoji:"😢",name:"crying face",category:"smileys",keywords:["cry"]},{emoji:"😭",name:"loudly crying face",category:"smileys",keywords:["sob"]},{emoji:"😱",name:"face screaming in fear",category:"smileys",keywords:["scream"]},{emoji:"😖",name:"confounded face",category:"smileys"},{emoji:"😣",name:"persevering face",category:"smileys"},{emoji:"😞",name:"disappointed face",category:"smileys"},{emoji:"😓",name:"downcast face with sweat",category:"smileys"},{emoji:"😩",name:"weary face",category:"smileys"},{emoji:"😫",name:"tired face",category:"smileys"},{emoji:"🥱",name:"yawning face",category:"smileys"},{emoji:"😤",name:"face with steam from nose",category:"smileys",keywords:["angry"]},{emoji:"😡",name:"pouting face",category:"smileys",keywords:["rage"]},{emoji:"😠",name:"angry face",category:"smileys"},{emoji:"🤬",name:"face with symbols on mouth",category:"smileys",keywords:["swear"]},{emoji:"😈",name:"smiling face with horns",category:"smileys",keywords:["devil"]},{emoji:"👿",name:"angry face with horns",category:"smileys"},{emoji:"💀",name:"skull",category:"smileys",keywords:["dead"]},{emoji:"☠️",name:"skull and crossbones",category:"smileys"},{emoji:"💩",name:"pile of poo",category:"smileys",keywords:["poop"]},{emoji:"🤡",name:"clown face",category:"smileys"},{emoji:"👹",name:"ogre",category:"smileys"},{emoji:"👺",name:"goblin",category:"smileys"},{emoji:"👻",name:"ghost",category:"smileys"},{emoji:"👽",name:"alien",category:"smileys"},{emoji:"👾",name:"alien monster",category:"smileys"},{emoji:"🤖",name:"robot",category:"smileys"},{emoji:"👋",name:"waving hand",category:"people",skinTones:!0,keywords:["wave","hi"]},{emoji:"🤚",name:"raised back of hand",category:"people",skinTones:!0},{emoji:"🖐️",name:"hand with fingers splayed",category:"people",skinTones:!0},{emoji:"✋",name:"raised hand",category:"people",skinTones:!0},{emoji:"🖖",name:"vulcan salute",category:"people",skinTones:!0},{emoji:"👌",name:"ok hand",category:"people",skinTones:!0,keywords:["ok","perfect"]},{emoji:"🤌",name:"pinched fingers",category:"people",skinTones:!0},{emoji:"🤏",name:"pinching hand",category:"people",skinTones:!0},{emoji:"✌️",name:"victory hand",category:"people",skinTones:!0,keywords:["peace"]},{emoji:"🤞",name:"crossed fingers",category:"people",skinTones:!0},{emoji:"🤟",name:"love-you gesture",category:"people",skinTones:!0},{emoji:"🤘",name:"sign of the horns",category:"people",skinTones:!0,keywords:["rock"]},{emoji:"🤙",name:"call me hand",category:"people",skinTones:!0},{emoji:"👈",name:"backhand index pointing left",category:"people",skinTones:!0},{emoji:"👉",name:"backhand index pointing right",category:"people",skinTones:!0},{emoji:"👆",name:"backhand index pointing up",category:"people",skinTones:!0},{emoji:"🖕",name:"middle finger",category:"people",skinTones:!0},{emoji:"👇",name:"backhand index pointing down",category:"people",skinTones:!0},{emoji:"☝️",name:"index pointing up",category:"people",skinTones:!0},{emoji:"👍",name:"thumbs up",category:"people",skinTones:!0,keywords:["like","good"]},{emoji:"👎",name:"thumbs down",category:"people",skinTones:!0,keywords:["dislike","bad"]},{emoji:"✊",name:"raised fist",category:"people",skinTones:!0},{emoji:"👊",name:"oncoming fist",category:"people",skinTones:!0},{emoji:"🤛",name:"left-facing fist",category:"people",skinTones:!0},{emoji:"🤜",name:"right-facing fist",category:"people",skinTones:!0},{emoji:"👏",name:"clapping hands",category:"people",skinTones:!0,keywords:["clap","applause"]},{emoji:"🙌",name:"raising hands",category:"people",skinTones:!0},{emoji:"👐",name:"open hands",category:"people",skinTones:!0},{emoji:"🤲",name:"palms up together",category:"people",skinTones:!0},{emoji:"🤝",name:"handshake",category:"people",skinTones:!0},{emoji:"🙏",name:"folded hands",category:"people",skinTones:!0,keywords:["pray","please"]},{emoji:"✍️",name:"writing hand",category:"people",skinTones:!0},{emoji:"💪",name:"flexed biceps",category:"people",skinTones:!0,keywords:["strong","muscle"]},{emoji:"🐶",name:"dog face",category:"animals",keywords:["dog"]},{emoji:"🐱",name:"cat face",category:"animals",keywords:["cat"]},{emoji:"🐭",name:"mouse face",category:"animals"},{emoji:"🐹",name:"hamster",category:"animals"},{emoji:"🐰",name:"rabbit face",category:"animals"},{emoji:"🦊",name:"fox",category:"animals"},{emoji:"🐻",name:"bear",category:"animals"},{emoji:"🐼",name:"panda",category:"animals"},{emoji:"🐨",name:"koala",category:"animals"},{emoji:"🐯",name:"tiger face",category:"animals"},{emoji:"🦁",name:"lion",category:"animals"},{emoji:"🐮",name:"cow face",category:"animals"},{emoji:"🐷",name:"pig face",category:"animals",keywords:["pig"]},{emoji:"🐸",name:"frog",category:"animals"},{emoji:"🐵",name:"monkey face",category:"animals"},{emoji:"🙈",name:"see-no-evil monkey",category:"animals"},{emoji:"🙉",name:"hear-no-evil monkey",category:"animals"},{emoji:"🙊",name:"speak-no-evil monkey",category:"animals"},{emoji:"🐔",name:"chicken",category:"animals"},{emoji:"🐧",name:"penguin",category:"animals"},{emoji:"🐦",name:"bird",category:"animals"},{emoji:"🐤",name:"baby chick",category:"animals"},{emoji:"🦆",name:"duck",category:"animals"},{emoji:"🦅",name:"eagle",category:"animals"},{emoji:"🦉",name:"owl",category:"animals"},{emoji:"🦇",name:"bat",category:"animals"},{emoji:"🐺",name:"wolf",category:"animals"},{emoji:"🐗",name:"boar",category:"animals"},{emoji:"🐴",name:"horse face",category:"animals"},{emoji:"🦄",name:"unicorn",category:"animals"},{emoji:"🐝",name:"honeybee",category:"animals",keywords:["bee"]},{emoji:"🐛",name:"bug",category:"animals"},{emoji:"🦋",name:"butterfly",category:"animals"},{emoji:"🐌",name:"snail",category:"animals"},{emoji:"🐙",name:"octopus",category:"animals"},{emoji:"🐬",name:"dolphin",category:"animals"},{emoji:"🐳",name:"spouting whale",category:"animals",keywords:["whale"]},{emoji:"🦈",name:"shark",category:"animals"},{emoji:"🐊",name:"crocodile",category:"animals"},{emoji:"🐢",name:"turtle",category:"animals"},{emoji:"🐍",name:"snake",category:"animals"},{emoji:"🦎",name:"lizard",category:"animals"},{emoji:"🐲",name:"dragon face",category:"animals",keywords:["dragon"]},{emoji:"🌸",name:"cherry blossom",category:"animals",keywords:["flower"]},{emoji:"🌹",name:"rose",category:"animals"},{emoji:"🌻",name:"sunflower",category:"animals"},{emoji:"🌺",name:"hibiscus",category:"animals"},{emoji:"🌷",name:"tulip",category:"animals"},{emoji:"🌲",name:"evergreen tree",category:"animals",keywords:["tree"]},{emoji:"🌳",name:"deciduous tree",category:"animals"},{emoji:"🌴",name:"palm tree",category:"animals"},{emoji:"🌵",name:"cactus",category:"animals"},{emoji:"🍀",name:"four leaf clover",category:"animals",keywords:["lucky"]},{emoji:"🍎",name:"red apple",category:"food",keywords:["apple"]},{emoji:"🍊",name:"tangerine",category:"food",keywords:["orange"]},{emoji:"🍋",name:"lemon",category:"food"},{emoji:"🍌",name:"banana",category:"food"},{emoji:"🍉",name:"watermelon",category:"food"},{emoji:"🍇",name:"grapes",category:"food"},{emoji:"🍓",name:"strawberry",category:"food"},{emoji:"🍒",name:"cherries",category:"food"},{emoji:"🍑",name:"peach",category:"food"},{emoji:"🥭",name:"mango",category:"food"},{emoji:"🍍",name:"pineapple",category:"food"},{emoji:"🥝",name:"kiwi fruit",category:"food"},{emoji:"🍅",name:"tomato",category:"food"},{emoji:"🥑",name:"avocado",category:"food"},{emoji:"🥦",name:"broccoli",category:"food"},{emoji:"🥬",name:"leafy green",category:"food"},{emoji:"🥒",name:"cucumber",category:"food"},{emoji:"🌽",name:"ear of corn",category:"food",keywords:["corn"]},{emoji:"🥕",name:"carrot",category:"food"},{emoji:"🧄",name:"garlic",category:"food"},{emoji:"🧅",name:"onion",category:"food"},{emoji:"🥔",name:"potato",category:"food"},{emoji:"🍞",name:"bread",category:"food"},{emoji:"🥐",name:"croissant",category:"food"},{emoji:"🥖",name:"baguette bread",category:"food"},{emoji:"🧀",name:"cheese wedge",category:"food",keywords:["cheese"]},{emoji:"🥚",name:"egg",category:"food"},{emoji:"🍳",name:"cooking",category:"food",keywords:["egg","breakfast"]},{emoji:"🥓",name:"bacon",category:"food"},{emoji:"🥩",name:"cut of meat",category:"food",keywords:["steak"]},{emoji:"🍗",name:"poultry leg",category:"food",keywords:["chicken"]},{emoji:"🍖",name:"meat on bone",category:"food"},{emoji:"🌭",name:"hot dog",category:"food"},{emoji:"🍔",name:"hamburger",category:"food",keywords:["burger"]},{emoji:"🍟",name:"french fries",category:"food",keywords:["fries"]},{emoji:"🍕",name:"pizza",category:"food"},{emoji:"🥪",name:"sandwich",category:"food"},{emoji:"🌮",name:"taco",category:"food"},{emoji:"🌯",name:"burrito",category:"food"},{emoji:"🥗",name:"green salad",category:"food",keywords:["salad"]},{emoji:"🍝",name:"spaghetti",category:"food",keywords:["pasta"]},{emoji:"🍜",name:"steaming bowl",category:"food",keywords:["ramen","noodles"]},{emoji:"🍲",name:"pot of food",category:"food",keywords:["stew"]},{emoji:"🍣",name:"sushi",category:"food"},{emoji:"🍱",name:"bento box",category:"food"},{emoji:"🥟",name:"dumpling",category:"food"},{emoji:"🍩",name:"doughnut",category:"food",keywords:["donut"]},{emoji:"🍪",name:"cookie",category:"food"},{emoji:"🎂",name:"birthday cake",category:"food",keywords:["cake","birthday"]},{emoji:"🍰",name:"shortcake",category:"food",keywords:["cake"]},{emoji:"🧁",name:"cupcake",category:"food"},{emoji:"🍫",name:"chocolate bar",category:"food",keywords:["chocolate"]},{emoji:"🍬",name:"candy",category:"food"},{emoji:"🍭",name:"lollipop",category:"food"},{emoji:"🍦",name:"soft ice cream",category:"food",keywords:["ice cream"]},{emoji:"☕",name:"hot beverage",category:"food",keywords:["coffee","tea"]},{emoji:"🍵",name:"teacup without handle",category:"food",keywords:["tea"]},{emoji:"🥤",name:"cup with straw",category:"food"},{emoji:"🍺",name:"beer mug",category:"food",keywords:["beer"]},{emoji:"🍻",name:"clinking beer mugs",category:"food",keywords:["cheers"]},{emoji:"🥂",name:"clinking glasses",category:"food",keywords:["champagne","toast"]},{emoji:"🍷",name:"wine glass",category:"food",keywords:["wine"]},{emoji:"🍸",name:"cocktail glass",category:"food",keywords:["martini"]},{emoji:"🚗",name:"automobile",category:"travel",keywords:["car"]},{emoji:"🚕",name:"taxi",category:"travel"},{emoji:"🚌",name:"bus",category:"travel"},{emoji:"🚎",name:"trolleybus",category:"travel"},{emoji:"🏎️",name:"racing car",category:"travel"},{emoji:"🚓",name:"police car",category:"travel"},{emoji:"🚑",name:"ambulance",category:"travel"},{emoji:"🚒",name:"fire engine",category:"travel"},{emoji:"🚐",name:"minibus",category:"travel"},{emoji:"🛻",name:"pickup truck",category:"travel"},{emoji:"🚚",name:"delivery truck",category:"travel",keywords:["truck"]},{emoji:"🚲",name:"bicycle",category:"travel",keywords:["bike"]},{emoji:"🛵",name:"motor scooter",category:"travel"},{emoji:"🏍️",name:"motorcycle",category:"travel"},{emoji:"✈️",name:"airplane",category:"travel",keywords:["plane"]},{emoji:"🚀",name:"rocket",category:"travel"},{emoji:"🚁",name:"helicopter",category:"travel"},{emoji:"🛶",name:"canoe",category:"travel"},{emoji:"⛵",name:"sailboat",category:"travel",keywords:["boat"]},{emoji:"🚢",name:"ship",category:"travel"},{emoji:"🚆",name:"train",category:"travel"},{emoji:"🚇",name:"metro",category:"travel",keywords:["subway"]},{emoji:"🏠",name:"house",category:"travel",keywords:["home"]},{emoji:"🏡",name:"house with garden",category:"travel"},{emoji:"🏢",name:"office building",category:"travel",keywords:["office"]},{emoji:"🏣",name:"Japanese post office",category:"travel"},{emoji:"🏥",name:"hospital",category:"travel"},{emoji:"🏦",name:"bank",category:"travel"},{emoji:"🏨",name:"hotel",category:"travel"},{emoji:"🏪",name:"convenience store",category:"travel",keywords:["store"]},{emoji:"🏫",name:"school",category:"travel"},{emoji:"🏭",name:"factory",category:"travel"},{emoji:"🏰",name:"castle",category:"travel"},{emoji:"⛪",name:"church",category:"travel"},{emoji:"🕌",name:"mosque",category:"travel"},{emoji:"🗼",name:"Tokyo tower",category:"travel"},{emoji:"🗽",name:"Statue of Liberty",category:"travel"},{emoji:"🌁",name:"foggy",category:"travel"},{emoji:"🌃",name:"night with stars",category:"travel"},{emoji:"🌄",name:"sunrise over mountains",category:"travel"},{emoji:"🌅",name:"sunrise",category:"travel"},{emoji:"🌆",name:"cityscape at dusk",category:"travel"},{emoji:"🌇",name:"sunset",category:"travel"},{emoji:"🌉",name:"bridge at night",category:"travel"},{emoji:"⛰️",name:"mountain",category:"travel"},{emoji:"🏔️",name:"snow-capped mountain",category:"travel"},{emoji:"🗻",name:"mount fuji",category:"travel"},{emoji:"🏝️",name:"desert island",category:"travel",keywords:["island"]},{emoji:"🏖️",name:"beach with umbrella",category:"travel",keywords:["beach"]},{emoji:"🌋",name:"volcano",category:"travel"},{emoji:"🌍",name:"globe Europe-Africa",category:"travel",keywords:["earth","world"]},{emoji:"🌎",name:"globe Americas",category:"travel"},{emoji:"🌏",name:"globe Asia-Australia",category:"travel"},{emoji:"🌕",name:"full moon",category:"travel",keywords:["moon"]},{emoji:"🌙",name:"crescent moon",category:"travel"},{emoji:"⭐",name:"star",category:"travel"},{emoji:"🌟",name:"glowing star",category:"travel"},{emoji:"☀️",name:"sun",category:"travel"},{emoji:"🌤️",name:"sun behind small cloud",category:"travel"},{emoji:"⛅",name:"sun behind cloud",category:"travel"},{emoji:"🌧️",name:"cloud with rain",category:"travel",keywords:["rain"]},{emoji:"⛈️",name:"cloud with lightning and rain",category:"travel",keywords:["storm"]},{emoji:"🌨️",name:"cloud with snow",category:"travel",keywords:["snow"]},{emoji:"🌈",name:"rainbow",category:"travel"},{emoji:"⚽",name:"soccer ball",category:"activities",keywords:["football","soccer"]},{emoji:"🏀",name:"basketball",category:"activities"},{emoji:"🏈",name:"american football",category:"activities"},{emoji:"⚾",name:"baseball",category:"activities"},{emoji:"🥎",name:"softball",category:"activities"},{emoji:"🎾",name:"tennis",category:"activities"},{emoji:"🏐",name:"volleyball",category:"activities"},{emoji:"🏉",name:"rugby football",category:"activities"},{emoji:"🥏",name:"flying disc",category:"activities",keywords:["frisbee"]},{emoji:"🎱",name:"pool 8 ball",category:"activities",keywords:["billiards"]},{emoji:"🪀",name:"yo-yo",category:"activities"},{emoji:"🏓",name:"ping pong",category:"activities"},{emoji:"🏸",name:"badminton",category:"activities"},{emoji:"🏒",name:"ice hockey",category:"activities"},{emoji:"🥅",name:"goal net",category:"activities"},{emoji:"⛳",name:"flag in hole",category:"activities",keywords:["golf"]},{emoji:"🏹",name:"bow and arrow",category:"activities",keywords:["archery"]},{emoji:"🎣",name:"fishing pole",category:"activities",keywords:["fishing"]},{emoji:"🥊",name:"boxing glove",category:"activities",keywords:["boxing"]},{emoji:"🥋",name:"martial arts uniform",category:"activities"},{emoji:"🎽",name:"running shirt",category:"activities"},{emoji:"🛹",name:"skateboard",category:"activities"},{emoji:"🛷",name:"sled",category:"activities"},{emoji:"⛸️",name:"ice skate",category:"activities"},{emoji:"🥌",name:"curling stone",category:"activities"},{emoji:"🎿",name:"skis",category:"activities",keywords:["skiing"]},{emoji:"🏂",name:"snowboarder",category:"activities",keywords:["snowboard"]},{emoji:"🏋️",name:"person lifting weights",category:"activities",keywords:["gym"]},{emoji:"🤸",name:"person cartwheeling",category:"activities"},{emoji:"🤺",name:"person fencing",category:"activities"},{emoji:"🏊",name:"person swimming",category:"activities",keywords:["swim"]},{emoji:"🚴",name:"person biking",category:"activities",keywords:["cycling"]},{emoji:"🧘",name:"person in lotus position",category:"activities",keywords:["yoga","meditation"]},{emoji:"🏆",name:"trophy",category:"activities",keywords:["winner","champion"]},{emoji:"🥇",name:"gold medal",category:"activities",keywords:["first"]},{emoji:"🥈",name:"silver medal",category:"activities",keywords:["second"]},{emoji:"🥉",name:"bronze medal",category:"activities",keywords:["third"]},{emoji:"🎮",name:"video game",category:"activities",keywords:["game","gaming"]},{emoji:"🕹️",name:"joystick",category:"activities"},{emoji:"🎲",name:"game die",category:"activities",keywords:["dice"]},{emoji:"🧩",name:"puzzle piece",category:"activities",keywords:["puzzle"]},{emoji:"♟️",name:"chess pawn",category:"activities",keywords:["chess"]},{emoji:"🎯",name:"direct hit",category:"activities",keywords:["dart","target"]},{emoji:"🎰",name:"slot machine",category:"activities"},{emoji:"🎭",name:"performing arts",category:"activities",keywords:["theater","drama"]},{emoji:"🎨",name:"artist palette",category:"activities",keywords:["art","paint"]},{emoji:"🎬",name:"clapper board",category:"activities",keywords:["movie","film"]},{emoji:"🎤",name:"microphone",category:"activities",keywords:["karaoke","sing"]},{emoji:"🎧",name:"headphone",category:"activities",keywords:["music"]},{emoji:"🎼",name:"musical score",category:"activities"},{emoji:"🎹",name:"musical keyboard",category:"activities",keywords:["piano"]},{emoji:"🎷",name:"saxophone",category:"activities"},{emoji:"🎸",name:"guitar",category:"activities"},{emoji:"🎻",name:"violin",category:"activities"},{emoji:"🪘",name:"long drum",category:"activities"},{emoji:"🥁",name:"drum",category:"activities"},{emoji:"⌚",name:"watch",category:"objects"},{emoji:"📱",name:"mobile phone",category:"objects",keywords:["phone","smartphone"]},{emoji:"📲",name:"mobile phone with arrow",category:"objects"},{emoji:"💻",name:"laptop",category:"objects",keywords:["computer"]},{emoji:"🖥️",name:"desktop computer",category:"objects"},{emoji:"🖨️",name:"printer",category:"objects"},{emoji:"⌨️",name:"keyboard",category:"objects"},{emoji:"🖱️",name:"computer mouse",category:"objects"},{emoji:"💾",name:"floppy disk",category:"objects"},{emoji:"💿",name:"optical disk",category:"objects",keywords:["cd"]},{emoji:"📀",name:"dvd",category:"objects"},{emoji:"📷",name:"camera",category:"objects"},{emoji:"📹",name:"video camera",category:"objects"},{emoji:"🎥",name:"movie camera",category:"objects"},{emoji:"📺",name:"television",category:"objects",keywords:["tv"]},{emoji:"📻",name:"radio",category:"objects"},{emoji:"🎙️",name:"studio microphone",category:"objects"},{emoji:"⏰",name:"alarm clock",category:"objects",keywords:["clock"]},{emoji:"⏳",name:"hourglass not done",category:"objects"},{emoji:"⌛",name:"hourglass done",category:"objects"},{emoji:"📡",name:"satellite antenna",category:"objects"},{emoji:"🔋",name:"battery",category:"objects"},{emoji:"🔌",name:"electric plug",category:"objects"},{emoji:"💡",name:"light bulb",category:"objects",keywords:["idea"]},{emoji:"🔦",name:"flashlight",category:"objects"},{emoji:"🕯️",name:"candle",category:"objects"},{emoji:"🧯",name:"fire extinguisher",category:"objects"},{emoji:"🛢️",name:"oil drum",category:"objects"},{emoji:"💸",name:"money with wings",category:"objects"},{emoji:"💵",name:"dollar banknote",category:"objects",keywords:["money"]},{emoji:"💳",name:"credit card",category:"objects"},{emoji:"💰",name:"money bag",category:"objects"},{emoji:"🧲",name:"magnet",category:"objects"},{emoji:"🔧",name:"wrench",category:"objects"},{emoji:"🔨",name:"hammer",category:"objects"},{emoji:"🛠️",name:"hammer and wrench",category:"objects",keywords:["tools"]},{emoji:"⚙️",name:"gear",category:"objects",keywords:["settings"]},{emoji:"🔩",name:"nut and bolt",category:"objects"},{emoji:"🔑",name:"key",category:"objects"},{emoji:"🗝️",name:"old key",category:"objects"},{emoji:"🔒",name:"locked",category:"objects",keywords:["lock"]},{emoji:"🔓",name:"unlocked",category:"objects"},{emoji:"📦",name:"package",category:"objects",keywords:["box"]},{emoji:"📫",name:"closed mailbox with raised flag",category:"objects",keywords:["mail"]},{emoji:"📝",name:"memo",category:"objects",keywords:["note"]},{emoji:"📄",name:"page facing up",category:"objects",keywords:["document"]},{emoji:"📁",name:"file folder",category:"objects",keywords:["folder"]},{emoji:"📂",name:"open file folder",category:"objects"},{emoji:"📅",name:"calendar",category:"objects"},{emoji:"📆",name:"tear-off calendar",category:"objects"},{emoji:"📌",name:"pushpin",category:"objects",keywords:["pin"]},{emoji:"📎",name:"paperclip",category:"objects"},{emoji:"✂️",name:"scissors",category:"objects"},{emoji:"📏",name:"straight ruler",category:"objects"},{emoji:"✏️",name:"pencil",category:"objects"},{emoji:"🖊️",name:"pen",category:"objects"},{emoji:"🖍️",name:"crayon",category:"objects"},{emoji:"📚",name:"books",category:"objects",keywords:["book","library"]},{emoji:"📖",name:"open book",category:"objects"},{emoji:"🔗",name:"link",category:"objects"},{emoji:"💊",name:"pill",category:"objects",keywords:["medicine"]},{emoji:"💉",name:"syringe",category:"objects"},{emoji:"🩹",name:"adhesive bandage",category:"objects"},{emoji:"🧪",name:"test tube",category:"objects"},{emoji:"🔬",name:"microscope",category:"objects"},{emoji:"🔭",name:"telescope",category:"objects"},{emoji:"🧬",name:"dna",category:"objects"},{emoji:"🗑️",name:"wastebasket",category:"objects",keywords:["trash","delete"]},{emoji:"🚿",name:"shower",category:"objects"},{emoji:"🛁",name:"bathtub",category:"objects"},{emoji:"🧹",name:"broom",category:"objects"},{emoji:"🧺",name:"basket",category:"objects"},{emoji:"🧻",name:"roll of paper",category:"objects"},{emoji:"🧼",name:"soap",category:"objects"},{emoji:"🪥",name:"toothbrush",category:"objects"},{emoji:"🛒",name:"shopping cart",category:"objects"},{emoji:"🎁",name:"wrapped gift",category:"objects",keywords:["gift","present"]},{emoji:"🎀",name:"ribbon",category:"objects"},{emoji:"🎈",name:"balloon",category:"objects"},{emoji:"🎉",name:"party popper",category:"objects",keywords:["party","celebration"]},{emoji:"🎊",name:"confetti ball",category:"objects"},{emoji:"❤️",name:"red heart",category:"symbols",keywords:["love","heart"]},{emoji:"🧡",name:"orange heart",category:"symbols"},{emoji:"💛",name:"yellow heart",category:"symbols"},{emoji:"💚",name:"green heart",category:"symbols"},{emoji:"💙",name:"blue heart",category:"symbols"},{emoji:"💜",name:"purple heart",category:"symbols"},{emoji:"🖤",name:"black heart",category:"symbols"},{emoji:"🤍",name:"white heart",category:"symbols"},{emoji:"🤎",name:"brown heart",category:"symbols"},{emoji:"💔",name:"broken heart",category:"symbols"},{emoji:"💕",name:"two hearts",category:"symbols"},{emoji:"💖",name:"sparkling heart",category:"symbols"},{emoji:"💗",name:"growing heart",category:"symbols"},{emoji:"💘",name:"heart with arrow",category:"symbols"},{emoji:"💝",name:"heart with ribbon",category:"symbols"},{emoji:"💞",name:"revolving hearts",category:"symbols"},{emoji:"💯",name:"hundred points",category:"symbols",keywords:["100","perfect"]},{emoji:"💢",name:"anger symbol",category:"symbols"},{emoji:"💥",name:"collision",category:"symbols",keywords:["boom","explosion"]},{emoji:"💫",name:"dizzy",category:"symbols"},{emoji:"💦",name:"sweat droplets",category:"symbols"},{emoji:"💨",name:"dashing away",category:"symbols"},{emoji:"🕳️",name:"hole",category:"symbols"},{emoji:"💬",name:"speech balloon",category:"symbols",keywords:["comment","chat"]},{emoji:"👁️🗨️",name:"eye in speech bubble",category:"symbols"},{emoji:"🗨️",name:"left speech bubble",category:"symbols"},{emoji:"🗯️",name:"right anger bubble",category:"symbols"},{emoji:"💭",name:"thought balloon",category:"symbols"},{emoji:"💤",name:"zzz",category:"symbols",keywords:["sleep"]},{emoji:"🔔",name:"bell",category:"symbols",keywords:["notification"]},{emoji:"🔕",name:"bell with slash",category:"symbols",keywords:["mute"]},{emoji:"🎵",name:"musical note",category:"symbols",keywords:["music"]},{emoji:"🎶",name:"musical notes",category:"symbols"},{emoji:"➕",name:"plus",category:"symbols",keywords:["add"]},{emoji:"➖",name:"minus",category:"symbols"},{emoji:"➗",name:"divide",category:"symbols"},{emoji:"✖️",name:"multiply",category:"symbols"},{emoji:"♾️",name:"infinity",category:"symbols"},{emoji:"💲",name:"heavy dollar sign",category:"symbols",keywords:["money"]},{emoji:"🔴",name:"red circle",category:"symbols"},{emoji:"🟠",name:"orange circle",category:"symbols"},{emoji:"🟡",name:"yellow circle",category:"symbols"},{emoji:"🟢",name:"green circle",category:"symbols"},{emoji:"🔵",name:"blue circle",category:"symbols"},{emoji:"🟣",name:"purple circle",category:"symbols"},{emoji:"⚫",name:"black circle",category:"symbols"},{emoji:"⚪",name:"white circle",category:"symbols"},{emoji:"🟤",name:"brown circle",category:"symbols"},{emoji:"🔺",name:"red triangle pointed up",category:"symbols"},{emoji:"🔻",name:"red triangle pointed down",category:"symbols"},{emoji:"🔷",name:"large blue diamond",category:"symbols"},{emoji:"🔶",name:"large orange diamond",category:"symbols"},{emoji:"✅",name:"check mark button",category:"symbols",keywords:["done","yes"]},{emoji:"❌",name:"cross mark",category:"symbols",keywords:["no","wrong"]},{emoji:"❎",name:"cross mark button",category:"symbols"},{emoji:"✔️",name:"check mark",category:"symbols"},{emoji:"⭕",name:"hollow red circle",category:"symbols"},{emoji:"❗",name:"exclamation mark",category:"symbols",keywords:["warning"]},{emoji:"❓",name:"question mark",category:"symbols"},{emoji:"❕",name:"white exclamation mark",category:"symbols"},{emoji:"❔",name:"white question mark",category:"symbols"},{emoji:"⚠️",name:"warning",category:"symbols"},{emoji:"🚫",name:"prohibited",category:"symbols",keywords:["no","forbidden"]},{emoji:"🔞",name:"no one under eighteen",category:"symbols"},{emoji:"⛔",name:"no entry",category:"symbols",keywords:["stop"]},{emoji:"🔙",name:"back arrow",category:"symbols"},{emoji:"🔚",name:"end arrow",category:"symbols"},{emoji:"🔛",name:"on! arrow",category:"symbols"},{emoji:"🔜",name:"soon arrow",category:"symbols"},{emoji:"🔝",name:"top arrow",category:"symbols"},{emoji:"🔃",name:"clockwise vertical arrows",category:"symbols",keywords:["refresh"]},{emoji:"🔄",name:"counterclockwise arrows button",category:"symbols",keywords:["sync"]},{emoji:"🔁",name:"repeat button",category:"symbols"},{emoji:"🔀",name:"shuffle tracks button",category:"symbols"},{emoji:"▶️",name:"play button",category:"symbols"},{emoji:"⏸️",name:"pause button",category:"symbols"},{emoji:"⏹️",name:"stop button",category:"symbols"},{emoji:"⏺️",name:"record button",category:"symbols"},{emoji:"⏭️",name:"next track button",category:"symbols"},{emoji:"⏮️",name:"last track button",category:"symbols"},{emoji:"⏩",name:"fast-forward button",category:"symbols"},{emoji:"⏪",name:"fast reverse button",category:"symbols"},{emoji:"🔼",name:"upwards button",category:"symbols"},{emoji:"🔽",name:"downwards button",category:"symbols"},{emoji:"⬆️",name:"up arrow",category:"symbols"},{emoji:"⬇️",name:"down arrow",category:"symbols"},{emoji:"⬅️",name:"left arrow",category:"symbols"},{emoji:"➡️",name:"right arrow",category:"symbols"},{emoji:"↗️",name:"up-right arrow",category:"symbols"},{emoji:"↘️",name:"down-right arrow",category:"symbols"},{emoji:"↙️",name:"down-left arrow",category:"symbols"},{emoji:"↖️",name:"up-left arrow",category:"symbols"},{emoji:"↕️",name:"up-down arrow",category:"symbols"},{emoji:"↔️",name:"left-right arrow",category:"symbols"},{emoji:"🔀",name:"shuffle",category:"symbols"},{emoji:"ℹ️",name:"information",category:"symbols",keywords:["info"]},{emoji:"🆕",name:"new button",category:"symbols",keywords:["new"]},{emoji:"🆗",name:"ok button",category:"symbols",keywords:["ok"]},{emoji:"🆙",name:"up! button",category:"symbols"},{emoji:"🆒",name:"cool button",category:"symbols",keywords:["cool"]},{emoji:"🆓",name:"free button",category:"symbols",keywords:["free"]},{emoji:"🔟",name:"keycap: 10",category:"symbols"},{emoji:"#️⃣",name:"keycap: #",category:"symbols"},{emoji:"*️⃣",name:"keycap: *",category:"symbols"},{emoji:"0️⃣",name:"keycap: 0",category:"symbols"},{emoji:"1️⃣",name:"keycap: 1",category:"symbols"},{emoji:"2️⃣",name:"keycap: 2",category:"symbols"},{emoji:"3️⃣",name:"keycap: 3",category:"symbols"},{emoji:"4️⃣",name:"keycap: 4",category:"symbols"},{emoji:"5️⃣",name:"keycap: 5",category:"symbols"},{emoji:"6️⃣",name:"keycap: 6",category:"symbols"},{emoji:"7️⃣",name:"keycap: 7",category:"symbols"},{emoji:"8️⃣",name:"keycap: 8",category:"symbols"},{emoji:"9️⃣",name:"keycap: 9",category:"symbols"},{emoji:"©️",name:"copyright",category:"symbols"},{emoji:"®️",name:"registered",category:"symbols"},{emoji:"™️",name:"trade mark",category:"symbols"},{emoji:"🏳️",name:"white flag",category:"flags"},{emoji:"🏴",name:"black flag",category:"flags"},{emoji:"🏁",name:"chequered flag",category:"flags",keywords:["finish","racing"]},{emoji:"🚩",name:"triangular flag",category:"flags"},{emoji:"🏳️🌈",name:"rainbow flag",category:"flags",keywords:["pride"]},{emoji:"🏳️⚧️",name:"transgender flag",category:"flags"},{emoji:"🇺🇸",name:"flag: United States",category:"flags",keywords:["usa","america"]},{emoji:"🇬🇧",name:"flag: United Kingdom",category:"flags",keywords:["uk","britain"]},{emoji:"🇩🇪",name:"flag: Germany",category:"flags"},{emoji:"🇫🇷",name:"flag: France",category:"flags"},{emoji:"🇵🇱",name:"flag: Poland",category:"flags"},{emoji:"🇪🇸",name:"flag: Spain",category:"flags"},{emoji:"🇮🇹",name:"flag: Italy",category:"flags"},{emoji:"🇯🇵",name:"flag: Japan",category:"flags"},{emoji:"🇨🇳",name:"flag: China",category:"flags"},{emoji:"🇰🇷",name:"flag: South Korea",category:"flags"},{emoji:"🇮🇳",name:"flag: India",category:"flags"},{emoji:"🇧🇷",name:"flag: Brazil",category:"flags"},{emoji:"🇷🇺",name:"flag: Russia",category:"flags"},{emoji:"🇦🇺",name:"flag: Australia",category:"flags"},{emoji:"🇨🇦",name:"flag: Canada",category:"flags"},{emoji:"🇲🇽",name:"flag: Mexico",category:"flags"},{emoji:"🇳🇱",name:"flag: Netherlands",category:"flags"},{emoji:"🇧🇪",name:"flag: Belgium",category:"flags"},{emoji:"🇨🇭",name:"flag: Switzerland",category:"flags"},{emoji:"🇦🇹",name:"flag: Austria",category:"flags"},{emoji:"🇸🇪",name:"flag: Sweden",category:"flags"},{emoji:"🇳🇴",name:"flag: Norway",category:"flags"},{emoji:"🇩🇰",name:"flag: Denmark",category:"flags"},{emoji:"🇫🇮",name:"flag: Finland",category:"flags"},{emoji:"🇵🇹",name:"flag: Portugal",category:"flags"},{emoji:"🇬🇷",name:"flag: Greece",category:"flags"},{emoji:"🇹🇷",name:"flag: Turkey",category:"flags"},{emoji:"🇮🇱",name:"flag: Israel",category:"flags"},{emoji:"🇦🇪",name:"flag: United Arab Emirates",category:"flags"},{emoji:"🇸🇦",name:"flag: Saudi Arabia",category:"flags"},{emoji:"🇿🇦",name:"flag: South Africa",category:"flags"},{emoji:"🇪🇬",name:"flag: Egypt",category:"flags"},{emoji:"🇳🇬",name:"flag: Nigeria",category:"flags"},{emoji:"🇹🇭",name:"flag: Thailand",category:"flags"},{emoji:"🇻🇳",name:"flag: Vietnam",category:"flags"},{emoji:"🇸🇬",name:"flag: Singapore",category:"flags"},{emoji:"🇲🇾",name:"flag: Malaysia",category:"flags"},{emoji:"🇮🇩",name:"flag: Indonesia",category:"flags"},{emoji:"🇵🇭",name:"flag: Philippines",category:"flags"},{emoji:"🇦🇷",name:"flag: Argentina",category:"flags"},{emoji:"🇨🇱",name:"flag: Chile",category:"flags"},{emoji:"🇨🇴",name:"flag: Colombia",category:"flags"},{emoji:"🇺🇦",name:"flag: Ukraine",category:"flags"},{emoji:"🇨🇿",name:"flag: Czech Republic",category:"flags"},{emoji:"🇭🇺",name:"flag: Hungary",category:"flags"},{emoji:"🇷🇴",name:"flag: Romania",category:"flags"},{emoji:"🇮🇪",name:"flag: Ireland",category:"flags"},{emoji:"🇳🇿",name:"flag: New Zealand",category:"flags"}],en="nice-emoji-picker-recent",Cn=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:a=!0,defaultSkinTone:s=0,showRecent:g=!0,maxRecent:x=24,recentEmojis:$,onRecentChange:P,categories:M,customEmojis:W=[],columns:J=8,size:B="md",className:I="",style:X,"data-testid":se="nice-emoji-picker"})=>{const oe=n.useRef(null);r.useRovingFocus(oe,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:ce}=r.useNiceTranslation(),[Z,F]=n.useState(""),[k,l]=n.useState(g?"recent":"smileys"),[T,Y]=n.useState(s),[A,_]=n.useState(!1),b=n.useRef(null),[C,f]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(en)||"[]")}catch{return[]}}),S=$??C,K=n.useMemo(()=>M??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],[M,g]),w=n.useMemo(()=>{if(!Z)return _t;const p=Z.toLowerCase();return _t.filter(E=>E.name.toLowerCase().includes(p)||E.emoji.includes(p)||E.keywords?.some(N=>N.toLowerCase().includes(p)))},[Z]),d=n.useMemo(()=>{const p={};for(const E of K)E==="recent"?p[E]=S.map(N=>_t.find(m=>m.emoji===N)).filter(N=>N!==void 0).slice(0,x):p[E]=w.filter(N=>N.category===E);return p},[K,w,S,x]),D=n.useCallback((p,E)=>!E||T===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+Et[T],[T]),j=n.useCallback(p=>{const E=D(p.emoji,p.skinTones),N=[p.emoji,...S.filter(m=>m!==p.emoji)].slice(0,x);if($===void 0){f(N);try{localStorage.setItem(en,JSON.stringify(N))}catch{}}P?.(N),t?.(E,p)},[D,S,x,$,P,t]),h=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!A)return;const p=E=>{b.current&&!b.current.contains(E.target)&&_(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[A]);const c=Z?w:d[k]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${B} ${I}`,style:X,"data-testid":se,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:Z,onChange:p=>F(p.target.value),placeholder:o??ce("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${se}-search`}),a&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:b,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>_(!A),title:ce("skinTone","Skin tone"),children:["✋",Et[T]]}),A&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:Et.map((p,E)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${E===T?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{Y(E),_(!1)},children:["✋",p]},E))})]})]}),!Z&&e.jsx("div",{className:"nice-emoji-picker__categories",ref:oe,role:"tablist",children:K.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${k===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>l(p),title:Qt[p],role:"tab","aria-selected":k===p,children:qi[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[Z?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ce("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:w.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ce("noEmojis","No emojis found")}):w.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>j(p),title:p.name,children:D(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Qt[k]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:c.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:k==="recent"?ce("noRecent","No recent emojis"):ce("noEmojis","No emojis found")}):c.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>j(p),title:p.name,children:D(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}),W.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ce("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:W.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>h(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};process.env.NODE_ENV!=="production"&&(Cn.displayName="NiceEmojiPicker");const Xi=Object.assign(n.forwardRef(({length:t=6,value:i="",onChange:o,masked:a=!1,onComplete:s,label:g,helperText:x,error:$,required:P,disabled:M,readOnly:W,size:J="md",name:B,id:I,className:X,style:se,autoFocus:oe,labelPlacement:ce,errorPlacement:Z,labelWidth:F,controlWidth:k,loading:l,cellWidth:T,...Y},A)=>{const _=r.useControlId(I),b=n.useRef([]),C=i.padEnd(t,"").slice(0,t).split(""),f=n.useCallback(D=>{const j=Math.max(0,Math.min(t-1,D));b.current[j]?.focus()},[t]),S=n.useCallback(D=>{const j=D.join("");o?.(j),j.length===t&&j.indexOf("")===-1&&/^\d+$/.test(j)&&s?.(j)},[o,s,t]),K=n.useCallback((D,j)=>{const c=j.target.value.replace(/\D/g,"").slice(-1);if(!c)return;const p=[...C];p[D]=c,S(p),f(D+1)},[C,S,f]),w=n.useCallback((D,j)=>{if(j.key==="Backspace"){j.preventDefault();const h=[...C];C[D]?(h[D]="",S(h)):D>0&&(h[D-1]="",S(h),f(D-1))}else j.key==="ArrowLeft"?(j.preventDefault(),f(D-1)):j.key==="ArrowRight"&&(j.preventDefault(),f(D+1))},[C,S,f]),d=n.useCallback(D=>{D.preventDefault();const j=D.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!j)return;const h=j.padEnd(t,"").slice(0,t).split("");for(let c=j.length;c<t;c++)h[c]=C[c]||"";S(h),f(Math.min(j.length,t-1))},[t,C,S,f]);return e.jsxs("div",{className:`nice-field nice-field--${J} nice-field--otp${ce?` nice-field--label-${ce}`:""}${Z==="right"?" nice-field--error-right":""} ${l?"nice-field--loading":""} ${X||""}`,style:{...se,...F!=null&&{"--nice-field-label-width":typeof F=="number"?`${F}px`:F},...k!=null&&{"--nice-field-control-width":typeof k=="number"?`${k}px`:k},...T!=null&&{"--nice-otp-cell-width":typeof T=="number"?`${T}px`:T}},"aria-busy":l||void 0,...Y,children:[g&&e.jsx("label",{htmlFor:`${_}-0`,className:`nice-field__label ${P?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:A,className:`nice-otp nice-otp--${J} ${$?"nice-otp--error":""} ${M?"nice-otp--disabled":""}`,onPaste:d,children:[Array.from({length:t},(D,j)=>e.jsx("input",{ref:h=>{b.current[j]=h},id:j===0?`${_}-0`:void 0,className:"nice-otp__digit",type:a?"password":"text",inputMode:"numeric",maxLength:2,value:C[j]||"",disabled:M,readOnly:W,autoFocus:oe&&j===0,"aria-invalid":!!$,"aria-label":`${j+1}`,onChange:h=>K(j,h),onKeyDown:h=>w(j,h),onFocus:h=>h.target.select()},j)),B&&e.jsx("input",{type:"hidden",name:B,value:i})]}),Z==="right"&&$&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:$}),Z==="right"&&!$&&x&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:x}),l&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),Z!=="right"&&$&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:$}),Z!=="right"&&!$&&x&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:x})]})}),{displayName:"NiceInputOtp"}),Vi=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],tn={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Gi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Wi=Object.assign(n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:a=Gi,showToolbar:s=!0,showZoom:g=!0,maxUndo:x=30,onSave:$,onCancel:P,onChange:M,width:W="100%",height:J=500,tutorial:B,className:I,style:X,id:se,...oe},ce)=>{const Z=r.useControlId(se),{t:F}=r.useNiceTranslation(),{prompt:k,element:l}=tt.useNiceDialogs(),T=n.useRef(null),Y=n.useRef(null);r.useRovingFocus(Y,{orientation:"horizontal",itemSelector:"button"});const A=n.useRef(null),[_,b]=n.useState({...tn}),[C,f]=n.useState(null),[S,K]=n.useState(!1),[w,d]=n.useState(1),[D,j]=n.useState("rect"),[h,c]=n.useState("var(--nice-danger, #ff0000)"),[p,E]=n.useState({w:0,h:0}),[N,m]=n.useState([]),[R,z]=n.useState([]),[ie,v]=n.useState(null),[ee,U]=n.useState(null),[me,pe]=n.useState(null),ye=n.useCallback(H=>{m(q=>[...q.slice(-(x-1)),H]),z([])},[x]),ue=n.useCallback(H=>{b(q=>{ye(q);const O={...q,...H};return M?.(O),O})},[M,ye]),he=n.useCallback(()=>{if(N.length===0)return;const H=N[N.length-1];m(q=>q.slice(0,-1)),z(q=>[...q,_]),b(H),M?.(H)},[N,_,M]),de=n.useCallback(()=>{if(R.length===0)return;const H=R[R.length-1];z(q=>q.slice(0,-1)),m(q=>[...q,_]),b(H),M?.(H)},[R,_,M]);n.useEffect(()=>{const H=new Image;H.crossOrigin="anonymous",H.onload=()=>{A.current=H,E({w:H.width,h:H.height}),K(!0)},H.src=t},[t]),n.useEffect(()=>{if(!S||!T.current||!A.current)return;const H=T.current,q=H.getContext("2d");if(!q)return;const O=A.current,y=_.rotation%180!==0,G=y?O.height:O.width,ne=y?O.width:O.height;H.width=G,H.height=ne,q.clearRect(0,0,G,ne),q.save(),q.filter=`brightness(${_.brightness}%) contrast(${_.contrast}%) saturate(${_.saturate}%) blur(${_.blur}px)`,q.translate(G/2,ne/2),q.rotate(_.rotation*Math.PI/180),q.scale(_.flipH?-1:1,_.flipV?-1:1),q.drawImage(O,-O.width/2,-O.height/2),q.restore(),_.annotations.forEach(le=>{switch(q.save(),q.strokeStyle=le.color??"red",q.fillStyle=le.color??"red",q.lineWidth=le.strokeWidth??2,q.font=`${le.fontSize??16}px sans-serif`,le.type){case"text":q.fillText(le.text??"",le.x,le.y);break;case"rect":q.strokeRect(le.x,le.y,le.width??100,le.height??50);break;case"circle":{const be=(le.width??50)/2,xe=(le.height??50)/2;q.beginPath(),q.ellipse(le.x+be,le.y+xe,be,xe,0,0,Math.PI*2),q.stroke();break}case"line":q.beginPath(),q.moveTo(le.x,le.y),q.lineTo(le.x+(le.width??100),le.y+(le.height??0)),q.stroke();break;case"arrow":{const be=le.x+(le.width??100),xe=le.y+(le.height??0);q.beginPath(),q.moveTo(le.x,le.y),q.lineTo(be,xe),q.stroke();const Se=Math.atan2(xe-le.y,be-le.x),Te=10;q.beginPath(),q.moveTo(be,xe),q.lineTo(be-Te*Math.cos(Se-.4),xe-Te*Math.sin(Se-.4)),q.lineTo(be-Te*Math.cos(Se+.4),xe-Te*Math.sin(Se+.4)),q.closePath(),q.fill();break}}q.restore()}),ee&&(q.save(),q.fillStyle=r.resolveCssColor("var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",q.canvas),q.fillRect(0,0,G,ne),q.clearRect(ee.x,ee.y,ee.w,ee.h),q.strokeStyle=r.resolveCssColor("var(--nice-bg-primary, #fff)",q.canvas),q.lineWidth=2,q.setLineDash([5,5]),q.strokeRect(ee.x,ee.y,ee.w,ee.h),q.restore())},[S,_,ee]);const ge=n.useCallback(H=>{if(!T.current)return;const q=T.current.getBoundingClientRect(),O=T.current.width/q.width,y=T.current.height/q.height,G=(H.clientX-q.left)*O,ne=(H.clientY-q.top)*y;C==="crop"?v({startX:G,startY:ne}):C==="annotate"&&pe({startX:G,startY:ne})},[C]),ae=n.useCallback(H=>{if(!T.current)return;const q=T.current.getBoundingClientRect(),O=T.current.width/q.width,y=T.current.height/q.height,G=(H.clientX-q.left)*O,ne=(H.clientY-q.top)*y;ie&&U({x:Math.min(ie.startX,G),y:Math.min(ie.startY,ne),w:Math.abs(G-ie.startX),h:Math.abs(ne-ie.startY)})},[ie]),ve=n.useCallback(H=>{if(ie&&ee&&ee.w>5&&ee.h>5&&ue({crop:{x:ee.x,y:ee.y,width:ee.w,height:ee.h}}),v(null),me&&T.current){const q=T.current.getBoundingClientRect(),O=T.current.width/q.width,y=T.current.height/q.height,G=(H.clientX-q.left)*O,ne=(H.clientY-q.top)*y,le=G-me.startX,be=ne-me.startY;if(Math.abs(le)>3||Math.abs(be)>3||D==="text"){const xe={type:D,x:me.startX,y:me.startY,width:Math.abs(le)||100,height:Math.abs(be)||50,color:h,strokeWidth:2};if(D==="text"){const Se=_.annotations;k({title:F("imageEditor.annotationText","Text:")}).then(Te=>{Te&&ue({annotations:[...Se,{...xe,text:Te}]})})}else ue({annotations:[..._.annotations,xe]})}pe(null)}},[ie,ee,me,D,h,_.annotations,ue,F,k]),_e=n.useCallback(()=>{if(!_.crop||!T.current)return;const H=T.current,q=H.getContext("2d");if(!q)return;const{x:O,y,width:G,height:ne}=_.crop,le=q.getImageData(O,y,G,ne);H.width=G,H.height=ne,q.putImageData(le,0,0),U(null),f(null)},[_.crop]),te=n.useCallback(()=>{if(!T.current)return;const H=T.current.toDataURL("image/png");$?.(H,_)},[$,_]),we=n.useCallback(()=>{b({...tn}),U(null),f(null)},[]);n.useMemo(()=>`brightness(${_.brightness}%) contrast(${_.contrast}%) saturate(${_.saturate}%) blur(${_.blur}px)`,[_.brightness,_.contrast,_.saturate,_.blur]);const re=s?e.jsxs("div",{ref:Y,className:"nice-image-editor__toolbar",role:"toolbar","aria-label":F("imageEditor.toolbar","Image tools"),children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:he,disabled:N.length===0,title:F("imageEditor.undo","Undo"),"aria-label":F("imageEditor.undo","Undo"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,disabled:R.length===0,title:F("imageEditor.redo","Redo"),"aria-label":F("imageEditor.redo","Redo"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),a.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({rotation:(_.rotation-90+360)%360}),title:F("imageEditor.rotateLeft","Rotate left"),"aria-label":F("imageEditor.rotateLeft","Rotate left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({rotation:(_.rotation+90)%360}),title:F("imageEditor.rotateRight","Rotate right"),"aria-label":F("imageEditor.rotateRight","Rotate right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),a.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({flipH:!_.flipH}),title:F("imageEditor.flipH","Flip horizontal"),"aria-label":F("imageEditor.flipH","Flip horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({flipV:!_.flipV}),title:F("imageEditor.flipV","Flip vertical"),"aria-label":F("imageEditor.flipV","Flip vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),a.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${C==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="crop"?null:"crop"),title:F("imageEditor.crop","Crop"),"aria-label":F("imageEditor.crop","Crop"),children:e.jsx(r.NiceIcon,{name:"box",size:16})}),C==="crop"&&_.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:_e,title:F("imageEditor.applyCrop","Apply crop"),"aria-label":F("imageEditor.applyCrop","Apply crop"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),a.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.brightness","Brightness"),children:[e.jsx(r.NiceIcon,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.brightness,onChange:H=>ue({brightness:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.brightness","Brightness")})]}),a.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.contrast","Contrast"),children:[e.jsx(r.NiceIcon,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.contrast,onChange:H=>ue({contrast:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.contrast","Contrast")})]}),a.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.saturate","Saturation"),children:[e.jsx(r.NiceIcon,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.saturate,onChange:H=>ue({saturate:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.saturate","Saturation")})]}),a.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.blur","Blur"),children:[e.jsx(r.NiceIcon,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:_.blur,onChange:H=>ue({blur:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.blur","Blur")})]}),a.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 ${C==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="annotate"?null:"annotate"),title:F("imageEditor.annotate","Annotate"),"aria-label":F("imageEditor.annotate","Annotate"),children:e.jsx(r.NiceIcon,{name:"edit",size:16})}),C==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:D,onChange:H=>j(H.target.value),children:[e.jsx("option",{value:"rect",children:F("imageEditor.rect","Rect")}),e.jsx("option",{value:"circle",children:F("imageEditor.circle","Circle")}),e.jsx("option",{value:"line",children:F("imageEditor.line","Line")}),e.jsx("option",{value:"arrow",children:F("imageEditor.arrow","Arrow")}),e.jsx("option",{value:"text",children:F("imageEditor.text","Text")})]}),e.jsx("input",{type:"color",value:h,onChange:H=>c(H.target.value),className:"nice-image-editor__color",title:F("imageEditor.color","Color")}),_.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({annotations:_.annotations.slice(0,-1)}),title:F("imageEditor.removeLastAnnotation","Remove last"),"aria-label":F("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(r.NiceIcon,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:we,title:F("imageEditor.reset","Reset"),"aria-label":F("imageEditor.reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})}),$&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:te,children:F("imageEditor.save","Save")}),P&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:P,children:F("imageEditor.cancel","Cancel")})]}):void 0,fe=g?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(H=>Math.max(.1,H-.1)),title:F("imageEditor.zoomOut","Zoom out"),"aria-label":F("imageEditor.zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(w*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(H=>Math.min(5,H+.1)),title:F("imageEditor.zoomIn","Zoom in"),"aria-label":F("imageEditor.zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(1),title:F("imageEditor.resetZoom","Reset zoom"),children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsx("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:F("imageEditor.px","{w}×{h}px · {rotation}°").replace("{w}",String(p.w)).replace("{h}",String(p.h)).replace("{rotation}",String(_.rotation))})]}):void 0;return e.jsxs(tt.NiceAppShell,{ref:ce,flush:!0,id:Z,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${I??""}`,style:{...X,width:W,height:J},toolbar:re,statusBar:fe,children:[l,e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":F("imageEditor.label","Image Editor"),...oe,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(B,Vi)})}),e.jsx("canvas",{ref:T,className:"nice-image-editor__canvas",onMouseDown:ge,onMouseMove:ae,onMouseUp:ve,style:{cursor:C==="crop"||C==="annotate"?"crosshair":"default",transform:`scale(${w})`,transformOrigin:"center center"}})]})]})}),{displayName:"NiceImageEditor"}),Ji={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Zi(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(o=>o.id===i.id?{...o,...i.updates}:o),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(o=>o.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const o=t.past[t.past.length-1];return{...t,annotations:o,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const o=t.future[0];return{...t,annotations:o,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Qi=0;function eo(){return`ann-${Date.now()}-${Qi++}`}function to(t){const{style:i}=t,o=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${o} />`;case"ellipse":{const a=t.x+t.width/2,s=t.y+t.height/2;return`<ellipse cx="${a}" cy="${s}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const a=t,s=Math.atan2(a.endY-a.y,a.endX-a.x),g=12,x=a.endX-g*Math.cos(s-Math.PI/6),$=a.endY-g*Math.sin(s-Math.PI/6),P=a.endX-g*Math.cos(s+Math.PI/6),M=a.endY-g*Math.sin(s+Math.PI/6);return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />
|
|
302
|
-
<polygon points="${a.endX},${a.endY} ${x},${$} ${P},${M}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const a=t;return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />`}case"text":{const a=t;return`<text x="${a.x}" y="${a.y+(a.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${
|
|
303
|
-
<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="transparent" stroke="none" filter="url(#${s})" />`}default:return""}}function
|
|
301
|
+
`,Oi=["street","streetNumber","apartment","city","postalCode","state","country"],yt={street:"Street",streetNumber:"Number",apartment:"Apt/Suite",city:"City",postalCode:"Postal Code",state:"State/Province",country:"Country"},Bi=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B={},onChange:I,fields:q=Oi,placeholders:se={},countries:oe,layout:ce="vertical",countryFirst:Z=!1,validatePostalCode:F},k)=>{const l=r.useNiceAccessMode(J,P),T=l==="hidden";l==="disabled"&&(s=!0),l==="readOnly"&&(g=!0);const{t:Y}=r.useNiceTranslation(),A=r.useControlId(P),_=n.useCallback((S,K)=>{I?.({...B,[S]:K})},[B,I]),b=n.useMemo(()=>{if(F&&B.postalCode)return F(B.postalCode,B.country)},[F,B.postalCode,B.country]),C=n.useMemo(()=>Z&&q.includes("country")?["country",...q.filter(S=>S!=="country")]:q,[q,Z]),f=`nice-address nice-address--${ce} nice-size-${x}`;return T?null:e.jsxs("div",{ref:k,id:A,className:`${f}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,role:"group","aria-label":t??Y("address","Address"),children:[t&&e.jsxs("label",{className:"nice-address__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-address__fields",children:C.map(S=>S==="country"&&oe?e.jsxs("div",{className:`nice-address__field nice-address__field--${S}`,children:[e.jsx("label",{className:"nice-address__field-label",children:Y(S,yt[S])}),e.jsxs("select",{className:"nice-input nice-select",value:B.country??"",onChange:K=>_("country",K.target.value),disabled:s,"aria-label":Y(S,yt[S]),children:[e.jsx("option",{value:"",children:se.country??Y("selectCountry","— Select country —")}),oe.map(K=>e.jsx("option",{value:K.code,children:K.name},K.code))]})]},S):e.jsxs("div",{className:`nice-address__field nice-address__field--${S}`,children:[e.jsx("label",{className:"nice-address__field-label",children:Y(S,yt[S])}),e.jsx("input",{className:`nice-input${S==="postalCode"&&b?" nice-input--error":""}`,type:"text",name:$?`${$}.${S}`:S,value:B[S]??"",onChange:K=>_(S,K.target.value),placeholder:se[S]??"",disabled:s,readOnly:g,"aria-label":Y(S,yt[S])}),S==="postalCode"&&b&&e.jsx("span",{className:"nice-error-text",children:b})]},S))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceAddressInput"}),Hi=[],Fi={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)"},Ki=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B,onChange:I,accounts:q=Hi,treeView:se=!1,placeholder:oe,searchable:ce=!0,showType:Z=!0,onSearch:F},k)=>{const l=r.useNiceAccessMode(J,P),T=l==="hidden";l==="disabled"&&(s=!0),l==="readOnly"&&(g=!0);const{t:Y}=r.useNiceTranslation(),A=r.useControlId(P),[_,b]=n.useState(""),[C,f]=n.useState(!1),S=n.useMemo(()=>{const m=R=>{for(const z of R){if(z.code===B)return z;if(z.children){const ie=m(z.children);if(ie)return ie}}};return m(q)},[q,B]),K=n.useMemo(()=>{const m=[],R=z=>{for(const ie of z)m.push(ie),ie.children&&R(ie.children)};return R(q),m},[q]),w=n.useMemo(()=>{if(!_)return K;const m=_.toLowerCase();return K.filter(R=>R.code.toLowerCase().includes(m)||R.name.toLowerCase().includes(m))},[K,_]),d=n.useCallback(m=>{b(m),F?.(m),f(!0)},[F]),D=n.useCallback(m=>{I?.(m.code,m),f(!1),b("")},[I]),j=n.useRef(null),h=C&&w.length>0,{activeIndex:c,setActiveIndex:p,handleKeyDown:E}=pt.useListKeyboardNav(w,{open:h,onSelect:m=>D(m),onClose:()=>f(!1),onOpen:()=>{p(0),f(!0)},intentRef:j}),N=`${A}-accounts`;return T?null:e.jsxs("div",{ref:k,id:A,className:`nice-account-picker nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-account-picker__label",htmlFor:`${A}-input`,children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),e.jsx("div",{className:"nice-account-picker__control",children:ce&&!g?e.jsx("input",{ref:j,id:`${A}-input`,className:"nice-input",type:"text",value:C?_:S?`${S.code} — ${S.name}`:"",onChange:m=>{d(m.target.value),p(0)},onFocus:()=>{b(""),p(-1),f(!0)},onBlur:()=>setTimeout(()=>f(!1),200),onKeyDown:E,placeholder:oe??Y("searchAccount","Search account…"),disabled:s,required:a,autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":h,"aria-controls":h?N:void 0,"aria-activedescendant":h&&w[c]?`${N}-${c}`:void 0}):e.jsx("div",{className:"nice-account-picker__display",children:S?`${S.code} — ${S.name}`:oe??Y("selectAccount","Select account…")})}),h&&e.jsx("div",{className:"nice-account-picker__dropdown",role:"listbox",id:N,children:w.map((m,R)=>e.jsxs("div",{id:`${N}-${R}`,className:`nice-account-picker__option${m.code===B?" nice-account-picker__option--selected":""}${R===c?" nice-account-picker__option--active":""}${m.isActive===!1?" nice-account-picker__option--inactive":""}`,role:"option","aria-selected":m.code===B,onMouseEnter:()=>p(R),onClick:()=>D(m),children:[Z&&m.type&&e.jsx("span",{className:"nice-account-picker__type",style:{color:Fi[m.type]},title:m.type,children:e.jsx(r.NiceIcon,{name:"circle",size:10})}),e.jsx("span",{className:"nice-account-picker__code",children:m.code}),e.jsx("span",{className:"nice-account-picker__name",children:m.name})]},m.code))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceAccountPicker"}),Ui=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B=[],onChange:I,contacts:q=[],onSearch:se,searchDelay:oe=300,multiple:ce=!1,placeholder:Z,onContactClick:F,maxSelections:k},l)=>{const T=r.useNiceAccessMode(J,P),Y=T==="hidden";T==="disabled"&&(s=!0),T==="readOnly"&&(g=!0);const{t:A}=r.useNiceTranslation(),_=r.useControlId(P),[b,C]=n.useState(""),[f,S]=n.useState([]),[K,w]=n.useState(!1),[d,D]=n.useState(!1),j=n.useMemo(()=>{const v=[...q,...f],ee=new Map(v.map(U=>[U.id,U]));return B.map(U=>ee.get(U)).filter(Boolean)},[B,q,f]),h=n.useCallback(v=>{if(C(v),v.length<1){S([]),w(!1);return}if(se){D(!0);const me=setTimeout(async()=>{const pe=await se(v);S(pe),w(!0),D(!1)},oe);return()=>clearTimeout(me)}const ee=v.toLowerCase(),U=q.filter(me=>me.name.toLowerCase().includes(ee)||me.email?.toLowerCase().includes(ee)||me.phone?.includes(v));S(U),w(!0)},[se,q,oe]),c=n.useCallback(v=>{if(ce)if(B.includes(v.id))I?.(B.filter(ee=>ee!==v.id));else{if(k&&B.length>=k)return;I?.([...B,v.id])}else I?.([v.id]),w(!1),C("")},[B,I,ce,k]),p=n.useCallback(v=>{I?.(B.filter(ee=>ee!==v))},[B,I]),E=n.useRef(null),N=K&&f.length>0,{activeIndex:m,setActiveIndex:R,handleKeyDown:z}=pt.useListKeyboardNav(f,{open:N,onSelect:v=>c(v),onClose:()=>w(!1),onOpen:()=>{f.length>0&&(R(0),w(!0))},intentRef:E}),ie=`${_}-results`;return Y?null:e.jsxs("div",{ref:l,id:_,className:`nice-contact-picker nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:W,children:[t&&e.jsxs("label",{className:"nice-contact-picker__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}),j.length>0&&e.jsx("div",{className:"nice-contact-picker__chips",children:j.map(v=>e.jsxs("span",{role:F?"button":void 0,tabIndex:F?0:void 0,onKeyDown:F?r.clickOnActivationKey:void 0,className:"nice-contact-picker__chip",onClick:()=>F?.(v),children:[v.avatarUrl&&e.jsx("img",{src:v.avatarUrl,alt:"",className:"nice-contact-picker__chip-avatar"}),e.jsx("span",{children:v.name}),!g&&e.jsx("button",{type:"button",className:"nice-contact-picker__chip-remove",onClick:ee=>{ee.stopPropagation(),p(v.id)},disabled:s,"aria-label":A("controls.remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},v.id))}),!g&&e.jsxs("div",{className:"nice-contact-picker__search",children:[e.jsx("input",{ref:E,className:"nice-input",type:"text",value:b,onChange:v=>{h(v.target.value),R(0)},onFocus:()=>b.length>0&&w(!0),onBlur:()=>setTimeout(()=>w(!1),200),onKeyDown:z,placeholder:Z??A("searchContacts","Search contacts…"),disabled:s,"aria-label":A("contactPicker.search","Search contacts"),autoComplete:"off",role:"combobox","aria-autocomplete":"list","aria-expanded":N,"aria-controls":N?ie:void 0,"aria-activedescendant":N&&f[m]?`${ie}-${m}`:void 0}),d&&e.jsx("span",{className:"nice-contact-picker__spinner",children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]}),N&&e.jsx("div",{className:"nice-contact-picker__dropdown",role:"listbox",id:ie,"aria-multiselectable":ce||void 0,children:f.map((v,ee)=>e.jsxs("div",{id:`${ie}-${ee}`,className:`nice-contact-picker__option${B.includes(v.id)?" nice-contact-picker__option--selected":""}${ee===m?" nice-contact-picker__option--active":""}`,role:"option","aria-selected":B.includes(v.id),onMouseEnter:()=>R(ee),onClick:()=>c(v),children:[v.avatarUrl&&e.jsx("img",{src:v.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:v.name}),v.subtitle&&e.jsx("span",{className:"nice-contact-picker__option-subtitle",children:v.subtitle}),v.email&&e.jsx("span",{className:"nice-contact-picker__option-email",children:v.email})]}),v.type&&e.jsx("span",{className:"nice-contact-picker__option-type",children:e.jsx(r.NiceIcon,{name:v.type==="person"?"user":"building",size:16})})]},v.id))}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceContactPicker"}),Yi={recent:"🕒",smileys:"😀",people:"👋",animals:"🐱",food:"🍕",travel:"✈️",activities:"⚽",objects:"💡",symbols:"❤️",flags:"🏳️"},Zt={recent:"Recently Used",smileys:"Smileys & Emotion",people:"People & Body",animals:"Animals & Nature",food:"Food & Drink",travel:"Travel & Places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"},St=["","🏻","🏼","🏽","🏾","🏿"],vt=[{emoji:"😀",name:"grinning face",category:"smileys",keywords:["happy","smile"]},{emoji:"😃",name:"grinning face with big eyes",category:"smileys"},{emoji:"😄",name:"grinning face with smiling eyes",category:"smileys"},{emoji:"😁",name:"beaming face",category:"smileys"},{emoji:"😅",name:"grinning face with sweat",category:"smileys"},{emoji:"🤣",name:"rolling on the floor laughing",category:"smileys",keywords:["rofl"]},{emoji:"😂",name:"face with tears of joy",category:"smileys",keywords:["lol","laugh"]},{emoji:"🙂",name:"slightly smiling face",category:"smileys"},{emoji:"😉",name:"winking face",category:"smileys",keywords:["wink"]},{emoji:"😊",name:"smiling face with smiling eyes",category:"smileys"},{emoji:"😇",name:"smiling face with halo",category:"smileys",keywords:["angel"]},{emoji:"🥰",name:"smiling face with hearts",category:"smileys",keywords:["love"]},{emoji:"😍",name:"smiling face with heart-eyes",category:"smileys"},{emoji:"🤩",name:"star-struck",category:"smileys",keywords:["wow"]},{emoji:"😘",name:"face blowing a kiss",category:"smileys",keywords:["kiss"]},{emoji:"😗",name:"kissing face",category:"smileys"},{emoji:"😚",name:"kissing face with closed eyes",category:"smileys"},{emoji:"😋",name:"face savoring food",category:"smileys",keywords:["yum"]},{emoji:"😛",name:"face with tongue",category:"smileys"},{emoji:"😜",name:"winking face with tongue",category:"smileys"},{emoji:"🤪",name:"zany face",category:"smileys",keywords:["crazy"]},{emoji:"😝",name:"squinting face with tongue",category:"smileys"},{emoji:"🤑",name:"money-mouth face",category:"smileys"},{emoji:"🤗",name:"hugging face",category:"smileys",keywords:["hug"]},{emoji:"🤭",name:"face with hand over mouth",category:"smileys"},{emoji:"🤫",name:"shushing face",category:"smileys",keywords:["quiet"]},{emoji:"🤔",name:"thinking face",category:"smileys",keywords:["think","hmm"]},{emoji:"🤐",name:"zipper-mouth face",category:"smileys"},{emoji:"🤨",name:"face with raised eyebrow",category:"smileys"},{emoji:"😐",name:"neutral face",category:"smileys"},{emoji:"😑",name:"expressionless face",category:"smileys"},{emoji:"😶",name:"face without mouth",category:"smileys"},{emoji:"😏",name:"smirking face",category:"smileys",keywords:["smirk"]},{emoji:"😒",name:"unamused face",category:"smileys"},{emoji:"🙄",name:"face with rolling eyes",category:"smileys"},{emoji:"😬",name:"grimacing face",category:"smileys"},{emoji:"😮💨",name:"face exhaling",category:"smileys"},{emoji:"🤥",name:"lying face",category:"smileys"},{emoji:"😌",name:"relieved face",category:"smileys"},{emoji:"😔",name:"pensive face",category:"smileys",keywords:["sad"]},{emoji:"😪",name:"sleepy face",category:"smileys"},{emoji:"🤤",name:"drooling face",category:"smileys"},{emoji:"😴",name:"sleeping face",category:"smileys",keywords:["sleep","zzz"]},{emoji:"😷",name:"face with medical mask",category:"smileys",keywords:["sick"]},{emoji:"🤒",name:"face with thermometer",category:"smileys"},{emoji:"🤕",name:"face with head-bandage",category:"smileys"},{emoji:"🤢",name:"nauseated face",category:"smileys"},{emoji:"🤮",name:"face vomiting",category:"smileys"},{emoji:"🤧",name:"sneezing face",category:"smileys"},{emoji:"🥵",name:"hot face",category:"smileys"},{emoji:"🥶",name:"cold face",category:"smileys"},{emoji:"🥴",name:"woozy face",category:"smileys",keywords:["drunk"]},{emoji:"😵",name:"face with crossed-out eyes",category:"smileys"},{emoji:"🤯",name:"exploding head",category:"smileys",keywords:["mind blown"]},{emoji:"🤠",name:"cowboy hat face",category:"smileys"},{emoji:"🥳",name:"partying face",category:"smileys",keywords:["party"]},{emoji:"🥸",name:"disguised face",category:"smileys"},{emoji:"😎",name:"smiling face with sunglasses",category:"smileys",keywords:["cool"]},{emoji:"🤓",name:"nerd face",category:"smileys",keywords:["nerd"]},{emoji:"🧐",name:"face with monocle",category:"smileys"},{emoji:"😕",name:"confused face",category:"smileys"},{emoji:"😟",name:"worried face",category:"smileys"},{emoji:"🙁",name:"slightly frowning face",category:"smileys"},{emoji:"☹️",name:"frowning face",category:"smileys"},{emoji:"😮",name:"face with open mouth",category:"smileys",keywords:["surprised"]},{emoji:"😯",name:"hushed face",category:"smileys"},{emoji:"😲",name:"astonished face",category:"smileys"},{emoji:"😳",name:"flushed face",category:"smileys"},{emoji:"🥺",name:"pleading face",category:"smileys"},{emoji:"😦",name:"frowning face with open mouth",category:"smileys"},{emoji:"😧",name:"anguished face",category:"smileys"},{emoji:"😨",name:"fearful face",category:"smileys"},{emoji:"😰",name:"anxious face with sweat",category:"smileys"},{emoji:"😥",name:"sad but relieved face",category:"smileys"},{emoji:"😢",name:"crying face",category:"smileys",keywords:["cry"]},{emoji:"😭",name:"loudly crying face",category:"smileys",keywords:["sob"]},{emoji:"😱",name:"face screaming in fear",category:"smileys",keywords:["scream"]},{emoji:"😖",name:"confounded face",category:"smileys"},{emoji:"😣",name:"persevering face",category:"smileys"},{emoji:"😞",name:"disappointed face",category:"smileys"},{emoji:"😓",name:"downcast face with sweat",category:"smileys"},{emoji:"😩",name:"weary face",category:"smileys"},{emoji:"😫",name:"tired face",category:"smileys"},{emoji:"🥱",name:"yawning face",category:"smileys"},{emoji:"😤",name:"face with steam from nose",category:"smileys",keywords:["angry"]},{emoji:"😡",name:"pouting face",category:"smileys",keywords:["rage"]},{emoji:"😠",name:"angry face",category:"smileys"},{emoji:"🤬",name:"face with symbols on mouth",category:"smileys",keywords:["swear"]},{emoji:"😈",name:"smiling face with horns",category:"smileys",keywords:["devil"]},{emoji:"👿",name:"angry face with horns",category:"smileys"},{emoji:"💀",name:"skull",category:"smileys",keywords:["dead"]},{emoji:"☠️",name:"skull and crossbones",category:"smileys"},{emoji:"💩",name:"pile of poo",category:"smileys",keywords:["poop"]},{emoji:"🤡",name:"clown face",category:"smileys"},{emoji:"👹",name:"ogre",category:"smileys"},{emoji:"👺",name:"goblin",category:"smileys"},{emoji:"👻",name:"ghost",category:"smileys"},{emoji:"👽",name:"alien",category:"smileys"},{emoji:"👾",name:"alien monster",category:"smileys"},{emoji:"🤖",name:"robot",category:"smileys"},{emoji:"👋",name:"waving hand",category:"people",skinTones:!0,keywords:["wave","hi"]},{emoji:"🤚",name:"raised back of hand",category:"people",skinTones:!0},{emoji:"🖐️",name:"hand with fingers splayed",category:"people",skinTones:!0},{emoji:"✋",name:"raised hand",category:"people",skinTones:!0},{emoji:"🖖",name:"vulcan salute",category:"people",skinTones:!0},{emoji:"👌",name:"ok hand",category:"people",skinTones:!0,keywords:["ok","perfect"]},{emoji:"🤌",name:"pinched fingers",category:"people",skinTones:!0},{emoji:"🤏",name:"pinching hand",category:"people",skinTones:!0},{emoji:"✌️",name:"victory hand",category:"people",skinTones:!0,keywords:["peace"]},{emoji:"🤞",name:"crossed fingers",category:"people",skinTones:!0},{emoji:"🤟",name:"love-you gesture",category:"people",skinTones:!0},{emoji:"🤘",name:"sign of the horns",category:"people",skinTones:!0,keywords:["rock"]},{emoji:"🤙",name:"call me hand",category:"people",skinTones:!0},{emoji:"👈",name:"backhand index pointing left",category:"people",skinTones:!0},{emoji:"👉",name:"backhand index pointing right",category:"people",skinTones:!0},{emoji:"👆",name:"backhand index pointing up",category:"people",skinTones:!0},{emoji:"🖕",name:"middle finger",category:"people",skinTones:!0},{emoji:"👇",name:"backhand index pointing down",category:"people",skinTones:!0},{emoji:"☝️",name:"index pointing up",category:"people",skinTones:!0},{emoji:"👍",name:"thumbs up",category:"people",skinTones:!0,keywords:["like","good"]},{emoji:"👎",name:"thumbs down",category:"people",skinTones:!0,keywords:["dislike","bad"]},{emoji:"✊",name:"raised fist",category:"people",skinTones:!0},{emoji:"👊",name:"oncoming fist",category:"people",skinTones:!0},{emoji:"🤛",name:"left-facing fist",category:"people",skinTones:!0},{emoji:"🤜",name:"right-facing fist",category:"people",skinTones:!0},{emoji:"👏",name:"clapping hands",category:"people",skinTones:!0,keywords:["clap","applause"]},{emoji:"🙌",name:"raising hands",category:"people",skinTones:!0},{emoji:"👐",name:"open hands",category:"people",skinTones:!0},{emoji:"🤲",name:"palms up together",category:"people",skinTones:!0},{emoji:"🤝",name:"handshake",category:"people",skinTones:!0},{emoji:"🙏",name:"folded hands",category:"people",skinTones:!0,keywords:["pray","please"]},{emoji:"✍️",name:"writing hand",category:"people",skinTones:!0},{emoji:"💪",name:"flexed biceps",category:"people",skinTones:!0,keywords:["strong","muscle"]},{emoji:"🐶",name:"dog face",category:"animals",keywords:["dog"]},{emoji:"🐱",name:"cat face",category:"animals",keywords:["cat"]},{emoji:"🐭",name:"mouse face",category:"animals"},{emoji:"🐹",name:"hamster",category:"animals"},{emoji:"🐰",name:"rabbit face",category:"animals"},{emoji:"🦊",name:"fox",category:"animals"},{emoji:"🐻",name:"bear",category:"animals"},{emoji:"🐼",name:"panda",category:"animals"},{emoji:"🐨",name:"koala",category:"animals"},{emoji:"🐯",name:"tiger face",category:"animals"},{emoji:"🦁",name:"lion",category:"animals"},{emoji:"🐮",name:"cow face",category:"animals"},{emoji:"🐷",name:"pig face",category:"animals",keywords:["pig"]},{emoji:"🐸",name:"frog",category:"animals"},{emoji:"🐵",name:"monkey face",category:"animals"},{emoji:"🙈",name:"see-no-evil monkey",category:"animals"},{emoji:"🙉",name:"hear-no-evil monkey",category:"animals"},{emoji:"🙊",name:"speak-no-evil monkey",category:"animals"},{emoji:"🐔",name:"chicken",category:"animals"},{emoji:"🐧",name:"penguin",category:"animals"},{emoji:"🐦",name:"bird",category:"animals"},{emoji:"🐤",name:"baby chick",category:"animals"},{emoji:"🦆",name:"duck",category:"animals"},{emoji:"🦅",name:"eagle",category:"animals"},{emoji:"🦉",name:"owl",category:"animals"},{emoji:"🦇",name:"bat",category:"animals"},{emoji:"🐺",name:"wolf",category:"animals"},{emoji:"🐗",name:"boar",category:"animals"},{emoji:"🐴",name:"horse face",category:"animals"},{emoji:"🦄",name:"unicorn",category:"animals"},{emoji:"🐝",name:"honeybee",category:"animals",keywords:["bee"]},{emoji:"🐛",name:"bug",category:"animals"},{emoji:"🦋",name:"butterfly",category:"animals"},{emoji:"🐌",name:"snail",category:"animals"},{emoji:"🐙",name:"octopus",category:"animals"},{emoji:"🐬",name:"dolphin",category:"animals"},{emoji:"🐳",name:"spouting whale",category:"animals",keywords:["whale"]},{emoji:"🦈",name:"shark",category:"animals"},{emoji:"🐊",name:"crocodile",category:"animals"},{emoji:"🐢",name:"turtle",category:"animals"},{emoji:"🐍",name:"snake",category:"animals"},{emoji:"🦎",name:"lizard",category:"animals"},{emoji:"🐲",name:"dragon face",category:"animals",keywords:["dragon"]},{emoji:"🌸",name:"cherry blossom",category:"animals",keywords:["flower"]},{emoji:"🌹",name:"rose",category:"animals"},{emoji:"🌻",name:"sunflower",category:"animals"},{emoji:"🌺",name:"hibiscus",category:"animals"},{emoji:"🌷",name:"tulip",category:"animals"},{emoji:"🌲",name:"evergreen tree",category:"animals",keywords:["tree"]},{emoji:"🌳",name:"deciduous tree",category:"animals"},{emoji:"🌴",name:"palm tree",category:"animals"},{emoji:"🌵",name:"cactus",category:"animals"},{emoji:"🍀",name:"four leaf clover",category:"animals",keywords:["lucky"]},{emoji:"🍎",name:"red apple",category:"food",keywords:["apple"]},{emoji:"🍊",name:"tangerine",category:"food",keywords:["orange"]},{emoji:"🍋",name:"lemon",category:"food"},{emoji:"🍌",name:"banana",category:"food"},{emoji:"🍉",name:"watermelon",category:"food"},{emoji:"🍇",name:"grapes",category:"food"},{emoji:"🍓",name:"strawberry",category:"food"},{emoji:"🍒",name:"cherries",category:"food"},{emoji:"🍑",name:"peach",category:"food"},{emoji:"🥭",name:"mango",category:"food"},{emoji:"🍍",name:"pineapple",category:"food"},{emoji:"🥝",name:"kiwi fruit",category:"food"},{emoji:"🍅",name:"tomato",category:"food"},{emoji:"🥑",name:"avocado",category:"food"},{emoji:"🥦",name:"broccoli",category:"food"},{emoji:"🥬",name:"leafy green",category:"food"},{emoji:"🥒",name:"cucumber",category:"food"},{emoji:"🌽",name:"ear of corn",category:"food",keywords:["corn"]},{emoji:"🥕",name:"carrot",category:"food"},{emoji:"🧄",name:"garlic",category:"food"},{emoji:"🧅",name:"onion",category:"food"},{emoji:"🥔",name:"potato",category:"food"},{emoji:"🍞",name:"bread",category:"food"},{emoji:"🥐",name:"croissant",category:"food"},{emoji:"🥖",name:"baguette bread",category:"food"},{emoji:"🧀",name:"cheese wedge",category:"food",keywords:["cheese"]},{emoji:"🥚",name:"egg",category:"food"},{emoji:"🍳",name:"cooking",category:"food",keywords:["egg","breakfast"]},{emoji:"🥓",name:"bacon",category:"food"},{emoji:"🥩",name:"cut of meat",category:"food",keywords:["steak"]},{emoji:"🍗",name:"poultry leg",category:"food",keywords:["chicken"]},{emoji:"🍖",name:"meat on bone",category:"food"},{emoji:"🌭",name:"hot dog",category:"food"},{emoji:"🍔",name:"hamburger",category:"food",keywords:["burger"]},{emoji:"🍟",name:"french fries",category:"food",keywords:["fries"]},{emoji:"🍕",name:"pizza",category:"food"},{emoji:"🥪",name:"sandwich",category:"food"},{emoji:"🌮",name:"taco",category:"food"},{emoji:"🌯",name:"burrito",category:"food"},{emoji:"🥗",name:"green salad",category:"food",keywords:["salad"]},{emoji:"🍝",name:"spaghetti",category:"food",keywords:["pasta"]},{emoji:"🍜",name:"steaming bowl",category:"food",keywords:["ramen","noodles"]},{emoji:"🍲",name:"pot of food",category:"food",keywords:["stew"]},{emoji:"🍣",name:"sushi",category:"food"},{emoji:"🍱",name:"bento box",category:"food"},{emoji:"🥟",name:"dumpling",category:"food"},{emoji:"🍩",name:"doughnut",category:"food",keywords:["donut"]},{emoji:"🍪",name:"cookie",category:"food"},{emoji:"🎂",name:"birthday cake",category:"food",keywords:["cake","birthday"]},{emoji:"🍰",name:"shortcake",category:"food",keywords:["cake"]},{emoji:"🧁",name:"cupcake",category:"food"},{emoji:"🍫",name:"chocolate bar",category:"food",keywords:["chocolate"]},{emoji:"🍬",name:"candy",category:"food"},{emoji:"🍭",name:"lollipop",category:"food"},{emoji:"🍦",name:"soft ice cream",category:"food",keywords:["ice cream"]},{emoji:"☕",name:"hot beverage",category:"food",keywords:["coffee","tea"]},{emoji:"🍵",name:"teacup without handle",category:"food",keywords:["tea"]},{emoji:"🥤",name:"cup with straw",category:"food"},{emoji:"🍺",name:"beer mug",category:"food",keywords:["beer"]},{emoji:"🍻",name:"clinking beer mugs",category:"food",keywords:["cheers"]},{emoji:"🥂",name:"clinking glasses",category:"food",keywords:["champagne","toast"]},{emoji:"🍷",name:"wine glass",category:"food",keywords:["wine"]},{emoji:"🍸",name:"cocktail glass",category:"food",keywords:["martini"]},{emoji:"🚗",name:"automobile",category:"travel",keywords:["car"]},{emoji:"🚕",name:"taxi",category:"travel"},{emoji:"🚌",name:"bus",category:"travel"},{emoji:"🚎",name:"trolleybus",category:"travel"},{emoji:"🏎️",name:"racing car",category:"travel"},{emoji:"🚓",name:"police car",category:"travel"},{emoji:"🚑",name:"ambulance",category:"travel"},{emoji:"🚒",name:"fire engine",category:"travel"},{emoji:"🚐",name:"minibus",category:"travel"},{emoji:"🛻",name:"pickup truck",category:"travel"},{emoji:"🚚",name:"delivery truck",category:"travel",keywords:["truck"]},{emoji:"🚲",name:"bicycle",category:"travel",keywords:["bike"]},{emoji:"🛵",name:"motor scooter",category:"travel"},{emoji:"🏍️",name:"motorcycle",category:"travel"},{emoji:"✈️",name:"airplane",category:"travel",keywords:["plane"]},{emoji:"🚀",name:"rocket",category:"travel"},{emoji:"🚁",name:"helicopter",category:"travel"},{emoji:"🛶",name:"canoe",category:"travel"},{emoji:"⛵",name:"sailboat",category:"travel",keywords:["boat"]},{emoji:"🚢",name:"ship",category:"travel"},{emoji:"🚆",name:"train",category:"travel"},{emoji:"🚇",name:"metro",category:"travel",keywords:["subway"]},{emoji:"🏠",name:"house",category:"travel",keywords:["home"]},{emoji:"🏡",name:"house with garden",category:"travel"},{emoji:"🏢",name:"office building",category:"travel",keywords:["office"]},{emoji:"🏣",name:"Japanese post office",category:"travel"},{emoji:"🏥",name:"hospital",category:"travel"},{emoji:"🏦",name:"bank",category:"travel"},{emoji:"🏨",name:"hotel",category:"travel"},{emoji:"🏪",name:"convenience store",category:"travel",keywords:["store"]},{emoji:"🏫",name:"school",category:"travel"},{emoji:"🏭",name:"factory",category:"travel"},{emoji:"🏰",name:"castle",category:"travel"},{emoji:"⛪",name:"church",category:"travel"},{emoji:"🕌",name:"mosque",category:"travel"},{emoji:"🗼",name:"Tokyo tower",category:"travel"},{emoji:"🗽",name:"Statue of Liberty",category:"travel"},{emoji:"🌁",name:"foggy",category:"travel"},{emoji:"🌃",name:"night with stars",category:"travel"},{emoji:"🌄",name:"sunrise over mountains",category:"travel"},{emoji:"🌅",name:"sunrise",category:"travel"},{emoji:"🌆",name:"cityscape at dusk",category:"travel"},{emoji:"🌇",name:"sunset",category:"travel"},{emoji:"🌉",name:"bridge at night",category:"travel"},{emoji:"⛰️",name:"mountain",category:"travel"},{emoji:"🏔️",name:"snow-capped mountain",category:"travel"},{emoji:"🗻",name:"mount fuji",category:"travel"},{emoji:"🏝️",name:"desert island",category:"travel",keywords:["island"]},{emoji:"🏖️",name:"beach with umbrella",category:"travel",keywords:["beach"]},{emoji:"🌋",name:"volcano",category:"travel"},{emoji:"🌍",name:"globe Europe-Africa",category:"travel",keywords:["earth","world"]},{emoji:"🌎",name:"globe Americas",category:"travel"},{emoji:"🌏",name:"globe Asia-Australia",category:"travel"},{emoji:"🌕",name:"full moon",category:"travel",keywords:["moon"]},{emoji:"🌙",name:"crescent moon",category:"travel"},{emoji:"⭐",name:"star",category:"travel"},{emoji:"🌟",name:"glowing star",category:"travel"},{emoji:"☀️",name:"sun",category:"travel"},{emoji:"🌤️",name:"sun behind small cloud",category:"travel"},{emoji:"⛅",name:"sun behind cloud",category:"travel"},{emoji:"🌧️",name:"cloud with rain",category:"travel",keywords:["rain"]},{emoji:"⛈️",name:"cloud with lightning and rain",category:"travel",keywords:["storm"]},{emoji:"🌨️",name:"cloud with snow",category:"travel",keywords:["snow"]},{emoji:"🌈",name:"rainbow",category:"travel"},{emoji:"⚽",name:"soccer ball",category:"activities",keywords:["football","soccer"]},{emoji:"🏀",name:"basketball",category:"activities"},{emoji:"🏈",name:"american football",category:"activities"},{emoji:"⚾",name:"baseball",category:"activities"},{emoji:"🥎",name:"softball",category:"activities"},{emoji:"🎾",name:"tennis",category:"activities"},{emoji:"🏐",name:"volleyball",category:"activities"},{emoji:"🏉",name:"rugby football",category:"activities"},{emoji:"🥏",name:"flying disc",category:"activities",keywords:["frisbee"]},{emoji:"🎱",name:"pool 8 ball",category:"activities",keywords:["billiards"]},{emoji:"🪀",name:"yo-yo",category:"activities"},{emoji:"🏓",name:"ping pong",category:"activities"},{emoji:"🏸",name:"badminton",category:"activities"},{emoji:"🏒",name:"ice hockey",category:"activities"},{emoji:"🥅",name:"goal net",category:"activities"},{emoji:"⛳",name:"flag in hole",category:"activities",keywords:["golf"]},{emoji:"🏹",name:"bow and arrow",category:"activities",keywords:["archery"]},{emoji:"🎣",name:"fishing pole",category:"activities",keywords:["fishing"]},{emoji:"🥊",name:"boxing glove",category:"activities",keywords:["boxing"]},{emoji:"🥋",name:"martial arts uniform",category:"activities"},{emoji:"🎽",name:"running shirt",category:"activities"},{emoji:"🛹",name:"skateboard",category:"activities"},{emoji:"🛷",name:"sled",category:"activities"},{emoji:"⛸️",name:"ice skate",category:"activities"},{emoji:"🥌",name:"curling stone",category:"activities"},{emoji:"🎿",name:"skis",category:"activities",keywords:["skiing"]},{emoji:"🏂",name:"snowboarder",category:"activities",keywords:["snowboard"]},{emoji:"🏋️",name:"person lifting weights",category:"activities",keywords:["gym"]},{emoji:"🤸",name:"person cartwheeling",category:"activities"},{emoji:"🤺",name:"person fencing",category:"activities"},{emoji:"🏊",name:"person swimming",category:"activities",keywords:["swim"]},{emoji:"🚴",name:"person biking",category:"activities",keywords:["cycling"]},{emoji:"🧘",name:"person in lotus position",category:"activities",keywords:["yoga","meditation"]},{emoji:"🏆",name:"trophy",category:"activities",keywords:["winner","champion"]},{emoji:"🥇",name:"gold medal",category:"activities",keywords:["first"]},{emoji:"🥈",name:"silver medal",category:"activities",keywords:["second"]},{emoji:"🥉",name:"bronze medal",category:"activities",keywords:["third"]},{emoji:"🎮",name:"video game",category:"activities",keywords:["game","gaming"]},{emoji:"🕹️",name:"joystick",category:"activities"},{emoji:"🎲",name:"game die",category:"activities",keywords:["dice"]},{emoji:"🧩",name:"puzzle piece",category:"activities",keywords:["puzzle"]},{emoji:"♟️",name:"chess pawn",category:"activities",keywords:["chess"]},{emoji:"🎯",name:"direct hit",category:"activities",keywords:["dart","target"]},{emoji:"🎰",name:"slot machine",category:"activities"},{emoji:"🎭",name:"performing arts",category:"activities",keywords:["theater","drama"]},{emoji:"🎨",name:"artist palette",category:"activities",keywords:["art","paint"]},{emoji:"🎬",name:"clapper board",category:"activities",keywords:["movie","film"]},{emoji:"🎤",name:"microphone",category:"activities",keywords:["karaoke","sing"]},{emoji:"🎧",name:"headphone",category:"activities",keywords:["music"]},{emoji:"🎼",name:"musical score",category:"activities"},{emoji:"🎹",name:"musical keyboard",category:"activities",keywords:["piano"]},{emoji:"🎷",name:"saxophone",category:"activities"},{emoji:"🎸",name:"guitar",category:"activities"},{emoji:"🎻",name:"violin",category:"activities"},{emoji:"🪘",name:"long drum",category:"activities"},{emoji:"🥁",name:"drum",category:"activities"},{emoji:"⌚",name:"watch",category:"objects"},{emoji:"📱",name:"mobile phone",category:"objects",keywords:["phone","smartphone"]},{emoji:"📲",name:"mobile phone with arrow",category:"objects"},{emoji:"💻",name:"laptop",category:"objects",keywords:["computer"]},{emoji:"🖥️",name:"desktop computer",category:"objects"},{emoji:"🖨️",name:"printer",category:"objects"},{emoji:"⌨️",name:"keyboard",category:"objects"},{emoji:"🖱️",name:"computer mouse",category:"objects"},{emoji:"💾",name:"floppy disk",category:"objects"},{emoji:"💿",name:"optical disk",category:"objects",keywords:["cd"]},{emoji:"📀",name:"dvd",category:"objects"},{emoji:"📷",name:"camera",category:"objects"},{emoji:"📹",name:"video camera",category:"objects"},{emoji:"🎥",name:"movie camera",category:"objects"},{emoji:"📺",name:"television",category:"objects",keywords:["tv"]},{emoji:"📻",name:"radio",category:"objects"},{emoji:"🎙️",name:"studio microphone",category:"objects"},{emoji:"⏰",name:"alarm clock",category:"objects",keywords:["clock"]},{emoji:"⏳",name:"hourglass not done",category:"objects"},{emoji:"⌛",name:"hourglass done",category:"objects"},{emoji:"📡",name:"satellite antenna",category:"objects"},{emoji:"🔋",name:"battery",category:"objects"},{emoji:"🔌",name:"electric plug",category:"objects"},{emoji:"💡",name:"light bulb",category:"objects",keywords:["idea"]},{emoji:"🔦",name:"flashlight",category:"objects"},{emoji:"🕯️",name:"candle",category:"objects"},{emoji:"🧯",name:"fire extinguisher",category:"objects"},{emoji:"🛢️",name:"oil drum",category:"objects"},{emoji:"💸",name:"money with wings",category:"objects"},{emoji:"💵",name:"dollar banknote",category:"objects",keywords:["money"]},{emoji:"💳",name:"credit card",category:"objects"},{emoji:"💰",name:"money bag",category:"objects"},{emoji:"🧲",name:"magnet",category:"objects"},{emoji:"🔧",name:"wrench",category:"objects"},{emoji:"🔨",name:"hammer",category:"objects"},{emoji:"🛠️",name:"hammer and wrench",category:"objects",keywords:["tools"]},{emoji:"⚙️",name:"gear",category:"objects",keywords:["settings"]},{emoji:"🔩",name:"nut and bolt",category:"objects"},{emoji:"🔑",name:"key",category:"objects"},{emoji:"🗝️",name:"old key",category:"objects"},{emoji:"🔒",name:"locked",category:"objects",keywords:["lock"]},{emoji:"🔓",name:"unlocked",category:"objects"},{emoji:"📦",name:"package",category:"objects",keywords:["box"]},{emoji:"📫",name:"closed mailbox with raised flag",category:"objects",keywords:["mail"]},{emoji:"📝",name:"memo",category:"objects",keywords:["note"]},{emoji:"📄",name:"page facing up",category:"objects",keywords:["document"]},{emoji:"📁",name:"file folder",category:"objects",keywords:["folder"]},{emoji:"📂",name:"open file folder",category:"objects"},{emoji:"📅",name:"calendar",category:"objects"},{emoji:"📆",name:"tear-off calendar",category:"objects"},{emoji:"📌",name:"pushpin",category:"objects",keywords:["pin"]},{emoji:"📎",name:"paperclip",category:"objects"},{emoji:"✂️",name:"scissors",category:"objects"},{emoji:"📏",name:"straight ruler",category:"objects"},{emoji:"✏️",name:"pencil",category:"objects"},{emoji:"🖊️",name:"pen",category:"objects"},{emoji:"🖍️",name:"crayon",category:"objects"},{emoji:"📚",name:"books",category:"objects",keywords:["book","library"]},{emoji:"📖",name:"open book",category:"objects"},{emoji:"🔗",name:"link",category:"objects"},{emoji:"💊",name:"pill",category:"objects",keywords:["medicine"]},{emoji:"💉",name:"syringe",category:"objects"},{emoji:"🩹",name:"adhesive bandage",category:"objects"},{emoji:"🧪",name:"test tube",category:"objects"},{emoji:"🔬",name:"microscope",category:"objects"},{emoji:"🔭",name:"telescope",category:"objects"},{emoji:"🧬",name:"dna",category:"objects"},{emoji:"🗑️",name:"wastebasket",category:"objects",keywords:["trash","delete"]},{emoji:"🚿",name:"shower",category:"objects"},{emoji:"🛁",name:"bathtub",category:"objects"},{emoji:"🧹",name:"broom",category:"objects"},{emoji:"🧺",name:"basket",category:"objects"},{emoji:"🧻",name:"roll of paper",category:"objects"},{emoji:"🧼",name:"soap",category:"objects"},{emoji:"🪥",name:"toothbrush",category:"objects"},{emoji:"🛒",name:"shopping cart",category:"objects"},{emoji:"🎁",name:"wrapped gift",category:"objects",keywords:["gift","present"]},{emoji:"🎀",name:"ribbon",category:"objects"},{emoji:"🎈",name:"balloon",category:"objects"},{emoji:"🎉",name:"party popper",category:"objects",keywords:["party","celebration"]},{emoji:"🎊",name:"confetti ball",category:"objects"},{emoji:"❤️",name:"red heart",category:"symbols",keywords:["love","heart"]},{emoji:"🧡",name:"orange heart",category:"symbols"},{emoji:"💛",name:"yellow heart",category:"symbols"},{emoji:"💚",name:"green heart",category:"symbols"},{emoji:"💙",name:"blue heart",category:"symbols"},{emoji:"💜",name:"purple heart",category:"symbols"},{emoji:"🖤",name:"black heart",category:"symbols"},{emoji:"🤍",name:"white heart",category:"symbols"},{emoji:"🤎",name:"brown heart",category:"symbols"},{emoji:"💔",name:"broken heart",category:"symbols"},{emoji:"💕",name:"two hearts",category:"symbols"},{emoji:"💖",name:"sparkling heart",category:"symbols"},{emoji:"💗",name:"growing heart",category:"symbols"},{emoji:"💘",name:"heart with arrow",category:"symbols"},{emoji:"💝",name:"heart with ribbon",category:"symbols"},{emoji:"💞",name:"revolving hearts",category:"symbols"},{emoji:"💯",name:"hundred points",category:"symbols",keywords:["100","perfect"]},{emoji:"💢",name:"anger symbol",category:"symbols"},{emoji:"💥",name:"collision",category:"symbols",keywords:["boom","explosion"]},{emoji:"💫",name:"dizzy",category:"symbols"},{emoji:"💦",name:"sweat droplets",category:"symbols"},{emoji:"💨",name:"dashing away",category:"symbols"},{emoji:"🕳️",name:"hole",category:"symbols"},{emoji:"💬",name:"speech balloon",category:"symbols",keywords:["comment","chat"]},{emoji:"👁️🗨️",name:"eye in speech bubble",category:"symbols"},{emoji:"🗨️",name:"left speech bubble",category:"symbols"},{emoji:"🗯️",name:"right anger bubble",category:"symbols"},{emoji:"💭",name:"thought balloon",category:"symbols"},{emoji:"💤",name:"zzz",category:"symbols",keywords:["sleep"]},{emoji:"🔔",name:"bell",category:"symbols",keywords:["notification"]},{emoji:"🔕",name:"bell with slash",category:"symbols",keywords:["mute"]},{emoji:"🎵",name:"musical note",category:"symbols",keywords:["music"]},{emoji:"🎶",name:"musical notes",category:"symbols"},{emoji:"➕",name:"plus",category:"symbols",keywords:["add"]},{emoji:"➖",name:"minus",category:"symbols"},{emoji:"➗",name:"divide",category:"symbols"},{emoji:"✖️",name:"multiply",category:"symbols"},{emoji:"♾️",name:"infinity",category:"symbols"},{emoji:"💲",name:"heavy dollar sign",category:"symbols",keywords:["money"]},{emoji:"🔴",name:"red circle",category:"symbols"},{emoji:"🟠",name:"orange circle",category:"symbols"},{emoji:"🟡",name:"yellow circle",category:"symbols"},{emoji:"🟢",name:"green circle",category:"symbols"},{emoji:"🔵",name:"blue circle",category:"symbols"},{emoji:"🟣",name:"purple circle",category:"symbols"},{emoji:"⚫",name:"black circle",category:"symbols"},{emoji:"⚪",name:"white circle",category:"symbols"},{emoji:"🟤",name:"brown circle",category:"symbols"},{emoji:"🔺",name:"red triangle pointed up",category:"symbols"},{emoji:"🔻",name:"red triangle pointed down",category:"symbols"},{emoji:"🔷",name:"large blue diamond",category:"symbols"},{emoji:"🔶",name:"large orange diamond",category:"symbols"},{emoji:"✅",name:"check mark button",category:"symbols",keywords:["done","yes"]},{emoji:"❌",name:"cross mark",category:"symbols",keywords:["no","wrong"]},{emoji:"❎",name:"cross mark button",category:"symbols"},{emoji:"✔️",name:"check mark",category:"symbols"},{emoji:"⭕",name:"hollow red circle",category:"symbols"},{emoji:"❗",name:"exclamation mark",category:"symbols",keywords:["warning"]},{emoji:"❓",name:"question mark",category:"symbols"},{emoji:"❕",name:"white exclamation mark",category:"symbols"},{emoji:"❔",name:"white question mark",category:"symbols"},{emoji:"⚠️",name:"warning",category:"symbols"},{emoji:"🚫",name:"prohibited",category:"symbols",keywords:["no","forbidden"]},{emoji:"🔞",name:"no one under eighteen",category:"symbols"},{emoji:"⛔",name:"no entry",category:"symbols",keywords:["stop"]},{emoji:"🔙",name:"back arrow",category:"symbols"},{emoji:"🔚",name:"end arrow",category:"symbols"},{emoji:"🔛",name:"on! arrow",category:"symbols"},{emoji:"🔜",name:"soon arrow",category:"symbols"},{emoji:"🔝",name:"top arrow",category:"symbols"},{emoji:"🔃",name:"clockwise vertical arrows",category:"symbols",keywords:["refresh"]},{emoji:"🔄",name:"counterclockwise arrows button",category:"symbols",keywords:["sync"]},{emoji:"🔁",name:"repeat button",category:"symbols"},{emoji:"🔀",name:"shuffle tracks button",category:"symbols"},{emoji:"▶️",name:"play button",category:"symbols"},{emoji:"⏸️",name:"pause button",category:"symbols"},{emoji:"⏹️",name:"stop button",category:"symbols"},{emoji:"⏺️",name:"record button",category:"symbols"},{emoji:"⏭️",name:"next track button",category:"symbols"},{emoji:"⏮️",name:"last track button",category:"symbols"},{emoji:"⏩",name:"fast-forward button",category:"symbols"},{emoji:"⏪",name:"fast reverse button",category:"symbols"},{emoji:"🔼",name:"upwards button",category:"symbols"},{emoji:"🔽",name:"downwards button",category:"symbols"},{emoji:"⬆️",name:"up arrow",category:"symbols"},{emoji:"⬇️",name:"down arrow",category:"symbols"},{emoji:"⬅️",name:"left arrow",category:"symbols"},{emoji:"➡️",name:"right arrow",category:"symbols"},{emoji:"↗️",name:"up-right arrow",category:"symbols"},{emoji:"↘️",name:"down-right arrow",category:"symbols"},{emoji:"↙️",name:"down-left arrow",category:"symbols"},{emoji:"↖️",name:"up-left arrow",category:"symbols"},{emoji:"↕️",name:"up-down arrow",category:"symbols"},{emoji:"↔️",name:"left-right arrow",category:"symbols"},{emoji:"🔀",name:"shuffle",category:"symbols"},{emoji:"ℹ️",name:"information",category:"symbols",keywords:["info"]},{emoji:"🆕",name:"new button",category:"symbols",keywords:["new"]},{emoji:"🆗",name:"ok button",category:"symbols",keywords:["ok"]},{emoji:"🆙",name:"up! button",category:"symbols"},{emoji:"🆒",name:"cool button",category:"symbols",keywords:["cool"]},{emoji:"🆓",name:"free button",category:"symbols",keywords:["free"]},{emoji:"🔟",name:"keycap: 10",category:"symbols"},{emoji:"#️⃣",name:"keycap: #",category:"symbols"},{emoji:"*️⃣",name:"keycap: *",category:"symbols"},{emoji:"0️⃣",name:"keycap: 0",category:"symbols"},{emoji:"1️⃣",name:"keycap: 1",category:"symbols"},{emoji:"2️⃣",name:"keycap: 2",category:"symbols"},{emoji:"3️⃣",name:"keycap: 3",category:"symbols"},{emoji:"4️⃣",name:"keycap: 4",category:"symbols"},{emoji:"5️⃣",name:"keycap: 5",category:"symbols"},{emoji:"6️⃣",name:"keycap: 6",category:"symbols"},{emoji:"7️⃣",name:"keycap: 7",category:"symbols"},{emoji:"8️⃣",name:"keycap: 8",category:"symbols"},{emoji:"9️⃣",name:"keycap: 9",category:"symbols"},{emoji:"©️",name:"copyright",category:"symbols"},{emoji:"®️",name:"registered",category:"symbols"},{emoji:"™️",name:"trade mark",category:"symbols"},{emoji:"🏳️",name:"white flag",category:"flags"},{emoji:"🏴",name:"black flag",category:"flags"},{emoji:"🏁",name:"chequered flag",category:"flags",keywords:["finish","racing"]},{emoji:"🚩",name:"triangular flag",category:"flags"},{emoji:"🏳️🌈",name:"rainbow flag",category:"flags",keywords:["pride"]},{emoji:"🏳️⚧️",name:"transgender flag",category:"flags"},{emoji:"🇺🇸",name:"flag: United States",category:"flags",keywords:["usa","america"]},{emoji:"🇬🇧",name:"flag: United Kingdom",category:"flags",keywords:["uk","britain"]},{emoji:"🇩🇪",name:"flag: Germany",category:"flags"},{emoji:"🇫🇷",name:"flag: France",category:"flags"},{emoji:"🇵🇱",name:"flag: Poland",category:"flags"},{emoji:"🇪🇸",name:"flag: Spain",category:"flags"},{emoji:"🇮🇹",name:"flag: Italy",category:"flags"},{emoji:"🇯🇵",name:"flag: Japan",category:"flags"},{emoji:"🇨🇳",name:"flag: China",category:"flags"},{emoji:"🇰🇷",name:"flag: South Korea",category:"flags"},{emoji:"🇮🇳",name:"flag: India",category:"flags"},{emoji:"🇧🇷",name:"flag: Brazil",category:"flags"},{emoji:"🇷🇺",name:"flag: Russia",category:"flags"},{emoji:"🇦🇺",name:"flag: Australia",category:"flags"},{emoji:"🇨🇦",name:"flag: Canada",category:"flags"},{emoji:"🇲🇽",name:"flag: Mexico",category:"flags"},{emoji:"🇳🇱",name:"flag: Netherlands",category:"flags"},{emoji:"🇧🇪",name:"flag: Belgium",category:"flags"},{emoji:"🇨🇭",name:"flag: Switzerland",category:"flags"},{emoji:"🇦🇹",name:"flag: Austria",category:"flags"},{emoji:"🇸🇪",name:"flag: Sweden",category:"flags"},{emoji:"🇳🇴",name:"flag: Norway",category:"flags"},{emoji:"🇩🇰",name:"flag: Denmark",category:"flags"},{emoji:"🇫🇮",name:"flag: Finland",category:"flags"},{emoji:"🇵🇹",name:"flag: Portugal",category:"flags"},{emoji:"🇬🇷",name:"flag: Greece",category:"flags"},{emoji:"🇹🇷",name:"flag: Turkey",category:"flags"},{emoji:"🇮🇱",name:"flag: Israel",category:"flags"},{emoji:"🇦🇪",name:"flag: United Arab Emirates",category:"flags"},{emoji:"🇸🇦",name:"flag: Saudi Arabia",category:"flags"},{emoji:"🇿🇦",name:"flag: South Africa",category:"flags"},{emoji:"🇪🇬",name:"flag: Egypt",category:"flags"},{emoji:"🇳🇬",name:"flag: Nigeria",category:"flags"},{emoji:"🇹🇭",name:"flag: Thailand",category:"flags"},{emoji:"🇻🇳",name:"flag: Vietnam",category:"flags"},{emoji:"🇸🇬",name:"flag: Singapore",category:"flags"},{emoji:"🇲🇾",name:"flag: Malaysia",category:"flags"},{emoji:"🇮🇩",name:"flag: Indonesia",category:"flags"},{emoji:"🇵🇭",name:"flag: Philippines",category:"flags"},{emoji:"🇦🇷",name:"flag: Argentina",category:"flags"},{emoji:"🇨🇱",name:"flag: Chile",category:"flags"},{emoji:"🇨🇴",name:"flag: Colombia",category:"flags"},{emoji:"🇺🇦",name:"flag: Ukraine",category:"flags"},{emoji:"🇨🇿",name:"flag: Czech Republic",category:"flags"},{emoji:"🇭🇺",name:"flag: Hungary",category:"flags"},{emoji:"🇷🇴",name:"flag: Romania",category:"flags"},{emoji:"🇮🇪",name:"flag: Ireland",category:"flags"},{emoji:"🇳🇿",name:"flag: New Zealand",category:"flags"}],Qt="nice-emoji-picker-recent",Nn=({onSelect:t,showSearch:i=!0,searchPlaceholder:o,showSkinTones:a=!0,defaultSkinTone:s=0,showRecent:g=!0,maxRecent:x=24,recentEmojis:$,onRecentChange:P,categories:M,customEmojis:W=[],columns:J=8,size:B="md",className:I="",style:q,"data-testid":se="nice-emoji-picker"})=>{const oe=n.useRef(null);r.useRovingFocus(oe,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const{t:ce}=r.useNiceTranslation(),[Z,F]=n.useState(""),[k,l]=n.useState(g?"recent":"smileys"),[T,Y]=n.useState(s),[A,_]=n.useState(!1),b=n.useRef(null),[C,f]=n.useState(()=>{if(typeof window>"u")return[];try{return JSON.parse(localStorage.getItem(Qt)||"[]")}catch{return[]}}),S=$??C,K=n.useMemo(()=>M??[...g?["recent"]:[],"smileys","people","animals","food","travel","activities","objects","symbols","flags"],[M,g]),w=n.useMemo(()=>{if(!Z)return vt;const p=Z.toLowerCase();return vt.filter(E=>E.name.toLowerCase().includes(p)||E.emoji.includes(p)||E.keywords?.some(N=>N.toLowerCase().includes(p)))},[Z]),d=n.useMemo(()=>{const p={};for(const E of K)E==="recent"?p[E]=S.map(N=>vt.find(m=>m.emoji===N)).filter(N=>N!==void 0).slice(0,x):p[E]=w.filter(N=>N.category===E);return p},[K,w,S,x]),D=n.useCallback((p,E)=>!E||T===0?p:p.replace(/[\u{1F3FB}-\u{1F3FF}]/gu,"")+St[T],[T]),j=n.useCallback(p=>{const E=D(p.emoji,p.skinTones),N=[p.emoji,...S.filter(m=>m!==p.emoji)].slice(0,x);if($===void 0){f(N);try{localStorage.setItem(Qt,JSON.stringify(N))}catch{}}P?.(N),t?.(E,p)},[D,S,x,$,P,t]),h=n.useCallback(p=>{t?.(`:${p.name}:`,p)},[t]);n.useEffect(()=>{if(!A)return;const p=E=>{b.current&&!b.current.contains(E.target)&&_(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[A]);const c=Z?w:d[k]||[];return e.jsxs("div",{className:`nice-emoji-picker nice-emoji-picker--${B} ${I}`,style:q,"data-testid":se,children:[i&&e.jsxs("div",{className:"nice-emoji-picker__search",children:[e.jsx("input",{type:"text",value:Z,onChange:p=>F(p.target.value),placeholder:o??ce("search","Search emoji..."),className:"nice-emoji-picker__search-input","data-testid":`${se}-search`}),a&&e.jsxs("div",{className:"nice-emoji-picker__skin-tone-wrapper",children:[e.jsxs("button",{ref:b,type:"button",className:"nice-emoji-picker__skin-tone-btn",onClick:()=>_(!A),title:ce("skinTone","Skin tone"),children:["✋",St[T]]}),A&&e.jsx("div",{className:"nice-emoji-picker__skin-tone-menu",children:St.map((p,E)=>e.jsxs("button",{type:"button",className:`nice-emoji-picker__skin-tone-option ${E===T?"nice-emoji-picker__skin-tone-option--selected":""}`,onClick:()=>{Y(E),_(!1)},children:["✋",p]},E))})]})]}),!Z&&e.jsx("div",{className:"nice-emoji-picker__categories",ref:oe,role:"tablist",children:K.map(p=>e.jsx("button",{type:"button",className:`nice-emoji-picker__category-btn ${k===p?"nice-emoji-picker__category-btn--selected":""}`,onClick:()=>l(p),title:Zt[p],role:"tab","aria-selected":k===p,children:Yi[p]},p))}),e.jsxs("div",{className:"nice-emoji-picker__grid-container",children:[Z?e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ce("searchResults","Search Results")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:w.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:ce("noEmojis","No emojis found")}):w.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>j(p),title:p.name,children:D(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}):e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:Zt[k]}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:c.length===0?e.jsx("div",{className:"nice-emoji-picker__empty",children:k==="recent"?ce("noRecent","No recent emojis"):ce("noEmojis","No emojis found")}):c.map((p,E)=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji",onClick:()=>j(p),title:p.name,children:D(p.emoji,p.skinTones)},`${p.emoji}-${E}`))})]}),W.length>0&&e.jsxs("div",{className:"nice-emoji-picker__section",children:[e.jsx("div",{className:"nice-emoji-picker__section-title",children:ce("custom","Custom")}),e.jsx("div",{className:"nice-emoji-picker__grid",style:{gridTemplateColumns:`repeat(${J}, 1fr)`},children:W.map(p=>e.jsx("button",{type:"button",className:"nice-emoji-picker__emoji nice-emoji-picker__emoji--custom",onClick:()=>h(p),title:p.name,children:e.jsx("img",{src:p.url,alt:p.name})},p.id))})]})]})]})};process.env.NODE_ENV!=="production"&&(Nn.displayName="NiceEmojiPicker");const Xi=Object.assign(n.forwardRef(({length:t=6,value:i="",onChange:o,masked:a=!1,onComplete:s,label:g,helperText:x,error:$,required:P,disabled:M,readOnly:W,size:J="md",name:B,id:I,className:q,style:se,autoFocus:oe,labelPlacement:ce,errorPlacement:Z,labelWidth:F,controlWidth:k,loading:l,cellWidth:T,...Y},A)=>{const _=r.useControlId(I),b=n.useRef([]),C=i.padEnd(t,"").slice(0,t).split(""),f=n.useCallback(D=>{const j=Math.max(0,Math.min(t-1,D));b.current[j]?.focus()},[t]),S=n.useCallback(D=>{const j=D.join("");o?.(j),j.length===t&&j.indexOf("")===-1&&/^\d+$/.test(j)&&s?.(j)},[o,s,t]),K=n.useCallback((D,j)=>{const c=j.target.value.replace(/\D/g,"").slice(-1);if(!c)return;const p=[...C];p[D]=c,S(p),f(D+1)},[C,S,f]),w=n.useCallback((D,j)=>{if(j.key==="Backspace"){j.preventDefault();const h=[...C];C[D]?(h[D]="",S(h)):D>0&&(h[D-1]="",S(h),f(D-1))}else j.key==="ArrowLeft"?(j.preventDefault(),f(D-1)):j.key==="ArrowRight"&&(j.preventDefault(),f(D+1))},[C,S,f]),d=n.useCallback(D=>{D.preventDefault();const j=D.clipboardData.getData("text").replace(/\D/g,"").slice(0,t);if(!j)return;const h=j.padEnd(t,"").slice(0,t).split("");for(let c=j.length;c<t;c++)h[c]=C[c]||"";S(h),f(Math.min(j.length,t-1))},[t,C,S,f]);return e.jsxs("div",{className:`nice-field nice-field--${J} nice-field--otp${ce?` nice-field--label-${ce}`:""}${Z==="right"?" nice-field--error-right":""} ${l?"nice-field--loading":""} ${q||""}`,style:{...se,...F!=null&&{"--nice-field-label-width":typeof F=="number"?`${F}px`:F},...k!=null&&{"--nice-field-control-width":typeof k=="number"?`${k}px`:k},...T!=null&&{"--nice-otp-cell-width":typeof T=="number"?`${T}px`:T}},"aria-busy":l||void 0,...Y,children:[g&&e.jsx("label",{htmlFor:`${_}-0`,className:`nice-field__label ${P?"nice-field__label--required":""}`,children:g}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:A,className:`nice-otp nice-otp--${J} ${$?"nice-otp--error":""} ${M?"nice-otp--disabled":""}`,onPaste:d,children:[Array.from({length:t},(D,j)=>e.jsx("input",{ref:h=>{b.current[j]=h},id:j===0?`${_}-0`:void 0,className:"nice-otp__digit",type:a?"password":"text",inputMode:"numeric",maxLength:2,value:C[j]||"",disabled:M,readOnly:W,autoFocus:oe&&j===0,"aria-invalid":!!$,"aria-label":`${j+1}`,onChange:h=>K(j,h),onKeyDown:h=>w(j,h),onFocus:h=>h.target.select()},j)),B&&e.jsx("input",{type:"hidden",name:B,value:i})]}),Z==="right"&&$&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:$}),Z==="right"&&!$&&x&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:x}),l&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})})]}),Z!=="right"&&$&&e.jsx("div",{id:`${_}-error`,className:"nice-field__error",role:"alert",children:$}),Z!=="right"&&!$&&x&&e.jsx("div",{id:`${_}-helper`,className:"nice-field__helper",children:x})]})}),{displayName:"NiceInputOtp"}),qi=[{target:".nice-image-editor",titleKey:"tutorial.imageEditor.intro.title",title:"Image editor",contentKey:"tutorial.imageEditor.intro.content",content:"Use the toolbar to crop, rotate, flip, adjust brightness/contrast and annotate; undo/redo your edits, then save the result.",placement:"auto"}],en={rotation:0,flipH:!1,flipV:!1,brightness:100,contrast:100,saturate:100,blur:0,crop:null,annotations:[]},Vi=["crop","rotate","flip","brightness","contrast","saturate","blur","annotate"],Gi=Object.assign(n.forwardRef(({src:t,size:i="md",editorSize:o="standard",tools:a=Vi,showToolbar:s=!0,showZoom:g=!0,maxUndo:x=30,onSave:$,onCancel:P,onChange:M,width:W="100%",height:J=500,tutorial:B,className:I,style:q,id:se,...oe},ce)=>{const Z=r.useControlId(se),{t:F}=r.useNiceTranslation(),{prompt:k,element:l}=tt.useNiceDialogs(),T=n.useRef(null),Y=n.useRef(null);r.useRovingFocus(Y,{orientation:"horizontal",itemSelector:"button"});const A=n.useRef(null),[_,b]=n.useState({...en}),[C,f]=n.useState(null),[S,K]=n.useState(!1),[w,d]=n.useState(1),[D,j]=n.useState("rect"),[h,c]=n.useState("var(--nice-danger, #ff0000)"),[p,E]=n.useState({w:0,h:0}),[N,m]=n.useState([]),[R,z]=n.useState([]),[ie,v]=n.useState(null),[ee,U]=n.useState(null),[me,pe]=n.useState(null),ye=n.useCallback(H=>{m(X=>[...X.slice(-(x-1)),H]),z([])},[x]),ue=n.useCallback(H=>{b(X=>{ye(X);const O={...X,...H};return M?.(O),O})},[M,ye]),he=n.useCallback(()=>{if(N.length===0)return;const H=N[N.length-1];m(X=>X.slice(0,-1)),z(X=>[...X,_]),b(H),M?.(H)},[N,_,M]),de=n.useCallback(()=>{if(R.length===0)return;const H=R[R.length-1];z(X=>X.slice(0,-1)),m(X=>[...X,_]),b(H),M?.(H)},[R,_,M]);n.useEffect(()=>{const H=new Image;H.crossOrigin="anonymous",H.onload=()=>{A.current=H,E({w:H.width,h:H.height}),K(!0)},H.src=t},[t]),n.useEffect(()=>{if(!S||!T.current||!A.current)return;const H=T.current,X=H.getContext("2d");if(!X)return;const O=A.current,y=_.rotation%180!==0,G=y?O.height:O.width,ne=y?O.width:O.height;H.width=G,H.height=ne,X.clearRect(0,0,G,ne),X.save(),X.filter=`brightness(${_.brightness}%) contrast(${_.contrast}%) saturate(${_.saturate}%) blur(${_.blur}px)`,X.translate(G/2,ne/2),X.rotate(_.rotation*Math.PI/180),X.scale(_.flipH?-1:1,_.flipV?-1:1),X.drawImage(O,-O.width/2,-O.height/2),X.restore(),_.annotations.forEach(le=>{switch(X.save(),X.strokeStyle=le.color??"red",X.fillStyle=le.color??"red",X.lineWidth=le.strokeWidth??2,X.font=`${le.fontSize??16}px sans-serif`,le.type){case"text":X.fillText(le.text??"",le.x,le.y);break;case"rect":X.strokeRect(le.x,le.y,le.width??100,le.height??50);break;case"circle":{const be=(le.width??50)/2,xe=(le.height??50)/2;X.beginPath(),X.ellipse(le.x+be,le.y+xe,be,xe,0,0,Math.PI*2),X.stroke();break}case"line":X.beginPath(),X.moveTo(le.x,le.y),X.lineTo(le.x+(le.width??100),le.y+(le.height??0)),X.stroke();break;case"arrow":{const be=le.x+(le.width??100),xe=le.y+(le.height??0);X.beginPath(),X.moveTo(le.x,le.y),X.lineTo(be,xe),X.stroke();const Se=Math.atan2(xe-le.y,be-le.x),Te=10;X.beginPath(),X.moveTo(be,xe),X.lineTo(be-Te*Math.cos(Se-.4),xe-Te*Math.sin(Se-.4)),X.lineTo(be-Te*Math.cos(Se+.4),xe-Te*Math.sin(Se+.4)),X.closePath(),X.fill();break}}X.restore()}),ee&&(X.save(),X.fillStyle=r.resolveCssColor("var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",X.canvas),X.fillRect(0,0,G,ne),X.clearRect(ee.x,ee.y,ee.w,ee.h),X.strokeStyle=r.resolveCssColor("var(--nice-bg-primary, #fff)",X.canvas),X.lineWidth=2,X.setLineDash([5,5]),X.strokeRect(ee.x,ee.y,ee.w,ee.h),X.restore())},[S,_,ee]);const ge=n.useCallback(H=>{if(!T.current)return;const X=T.current.getBoundingClientRect(),O=T.current.width/X.width,y=T.current.height/X.height,G=(H.clientX-X.left)*O,ne=(H.clientY-X.top)*y;C==="crop"?v({startX:G,startY:ne}):C==="annotate"&&pe({startX:G,startY:ne})},[C]),ae=n.useCallback(H=>{if(!T.current)return;const X=T.current.getBoundingClientRect(),O=T.current.width/X.width,y=T.current.height/X.height,G=(H.clientX-X.left)*O,ne=(H.clientY-X.top)*y;ie&&U({x:Math.min(ie.startX,G),y:Math.min(ie.startY,ne),w:Math.abs(G-ie.startX),h:Math.abs(ne-ie.startY)})},[ie]),ve=n.useCallback(H=>{if(ie&&ee&&ee.w>5&&ee.h>5&&ue({crop:{x:ee.x,y:ee.y,width:ee.w,height:ee.h}}),v(null),me&&T.current){const X=T.current.getBoundingClientRect(),O=T.current.width/X.width,y=T.current.height/X.height,G=(H.clientX-X.left)*O,ne=(H.clientY-X.top)*y,le=G-me.startX,be=ne-me.startY;if(Math.abs(le)>3||Math.abs(be)>3||D==="text"){const xe={type:D,x:me.startX,y:me.startY,width:Math.abs(le)||100,height:Math.abs(be)||50,color:h,strokeWidth:2};if(D==="text"){const Se=_.annotations;k({title:F("imageEditor.annotationText","Text:")}).then(Te=>{Te&&ue({annotations:[...Se,{...xe,text:Te}]})})}else ue({annotations:[..._.annotations,xe]})}pe(null)}},[ie,ee,me,D,h,_.annotations,ue,F,k]),_e=n.useCallback(()=>{if(!_.crop||!T.current)return;const H=T.current,X=H.getContext("2d");if(!X)return;const{x:O,y,width:G,height:ne}=_.crop,le=X.getImageData(O,y,G,ne);H.width=G,H.height=ne,X.putImageData(le,0,0),U(null),f(null)},[_.crop]),te=n.useCallback(()=>{if(!T.current)return;const H=T.current.toDataURL("image/png");$?.(H,_)},[$,_]),we=n.useCallback(()=>{b({...en}),U(null),f(null)},[]);n.useMemo(()=>`brightness(${_.brightness}%) contrast(${_.contrast}%) saturate(${_.saturate}%) blur(${_.blur}px)`,[_.brightness,_.contrast,_.saturate,_.blur]);const re=s?e.jsxs("div",{ref:Y,className:"nice-image-editor__toolbar",role:"toolbar","aria-label":F("imageEditor.toolbar","Image tools"),children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:he,disabled:N.length===0,title:F("imageEditor.undo","Undo"),"aria-label":F("imageEditor.undo","Undo"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:de,disabled:R.length===0,title:F("imageEditor.redo","Redo"),"aria-label":F("imageEditor.redo","Redo"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})}),e.jsx("span",{className:"nice-image-editor__sep"}),a.includes("rotate")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({rotation:(_.rotation-90+360)%360}),title:F("imageEditor.rotateLeft","Rotate left"),"aria-label":F("imageEditor.rotateLeft","Rotate left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({rotation:(_.rotation+90)%360}),title:F("imageEditor.rotateRight","Rotate right"),"aria-label":F("imageEditor.rotateRight","Rotate right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),a.includes("flip")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({flipH:!_.flipH}),title:F("imageEditor.flipH","Flip horizontal"),"aria-label":F("imageEditor.flipH","Flip horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({flipV:!_.flipV}),title:F("imageEditor.flipV","Flip vertical"),"aria-label":F("imageEditor.flipV","Flip vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),a.includes("crop")&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-image-editor__btn ${C==="crop"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="crop"?null:"crop"),title:F("imageEditor.crop","Crop"),"aria-label":F("imageEditor.crop","Crop"),children:e.jsx(r.NiceIcon,{name:"box",size:16})}),C==="crop"&&_.crop&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:_e,title:F("imageEditor.applyCrop","Apply crop"),"aria-label":F("imageEditor.applyCrop","Apply crop"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),a.includes("brightness")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.brightness","Brightness"),children:[e.jsx(r.NiceIcon,{name:"lightbulb",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.brightness,onChange:H=>ue({brightness:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.brightness","Brightness")})]}),a.includes("contrast")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.contrast","Contrast"),children:[e.jsx(r.NiceIcon,{name:"circle",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.contrast,onChange:H=>ue({contrast:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.contrast","Contrast")})]}),a.includes("saturate")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.saturate","Saturation"),children:[e.jsx(r.NiceIcon,{name:"palette",size:16}),e.jsx("input",{type:"range",min:0,max:200,value:_.saturate,onChange:H=>ue({saturate:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.saturate","Saturation")})]}),a.includes("blur")&&e.jsxs("label",{className:"nice-image-editor__slider-label",title:F("imageEditor.blur","Blur"),children:[e.jsx(r.NiceIcon,{name:"eye-off",size:16}),e.jsx("input",{type:"range",min:0,max:20,step:.5,value:_.blur,onChange:H=>ue({blur:Number(H.target.value)}),className:"nice-image-editor__slider",title:F("imageEditor.blur","Blur")})]}),a.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 ${C==="annotate"?"nice-image-editor__btn--active":""}`,onClick:()=>f(C==="annotate"?null:"annotate"),title:F("imageEditor.annotate","Annotate"),"aria-label":F("imageEditor.annotate","Annotate"),children:e.jsx(r.NiceIcon,{name:"edit",size:16})}),C==="annotate"&&e.jsxs(e.Fragment,{children:[e.jsxs("select",{className:"nice-image-editor__select",value:D,onChange:H=>j(H.target.value),children:[e.jsx("option",{value:"rect",children:F("imageEditor.rect","Rect")}),e.jsx("option",{value:"circle",children:F("imageEditor.circle","Circle")}),e.jsx("option",{value:"line",children:F("imageEditor.line","Line")}),e.jsx("option",{value:"arrow",children:F("imageEditor.arrow","Arrow")}),e.jsx("option",{value:"text",children:F("imageEditor.text","Text")})]}),e.jsx("input",{type:"color",value:h,onChange:H=>c(H.target.value),className:"nice-image-editor__color",title:F("imageEditor.color","Color")}),_.annotations.length>0&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>ue({annotations:_.annotations.slice(0,-1)}),title:F("imageEditor.removeLastAnnotation","Remove last"),"aria-label":F("imageEditor.removeLastAnnotation","Remove last"),children:e.jsx(r.NiceIcon,{name:"trash",size:16})})]})]}),e.jsx("span",{className:"nice-image-editor__sep"}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:we,title:F("imageEditor.reset","Reset"),"aria-label":F("imageEditor.reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})}),$&&e.jsx("button",{type:"button",className:"nice-image-editor__btn nice-image-editor__btn--save",onClick:te,children:F("imageEditor.save","Save")}),P&&e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:P,children:F("imageEditor.cancel","Cancel")})]}):void 0,fe=g?e.jsxs("div",{className:"nice-image-editor__footer",children:[e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(H=>Math.max(.1,H-.1)),title:F("imageEditor.zoomOut","Zoom out"),"aria-label":F("imageEditor.zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{style:{fontSize:"0.85em",minWidth:40,textAlign:"center"},children:[Math.round(w*100),"%"]}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(H=>Math.min(5,H+.1)),title:F("imageEditor.zoomIn","Zoom in"),"aria-label":F("imageEditor.zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})}),e.jsx("button",{type:"button",className:"nice-image-editor__btn",onClick:()=>d(1),title:F("imageEditor.resetZoom","Reset zoom"),children:"1:1"}),e.jsx("span",{style:{flex:1}}),e.jsx("span",{style:{fontSize:"0.8em",color:"var(--nice-text-secondary, #666)"},children:F("imageEditor.px","{w}×{h}px · {rotation}°").replace("{w}",String(p.w)).replace("{h}",String(p.h)).replace("{rotation}",String(_.rotation))})]}):void 0;return e.jsxs(tt.NiceAppShell,{ref:ce,flush:!0,id:Z,className:`nice-image-editor nice-image-editor--${i} nice-editor--${o} ${I??""}`,style:{...q,width:W,height:J},toolbar:re,statusBar:fe,children:[l,e.jsxs("div",{className:"nice-image-editor__canvas-wrap",style:{position:"relative"},role:"application","aria-label":F("imageEditor.label","Image Editor"),...oe,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(B,qi)})}),e.jsx("canvas",{ref:T,className:"nice-image-editor__canvas",onMouseDown:ge,onMouseMove:ae,onMouseUp:ve,style:{cursor:C==="crop"||C==="annotate"?"crosshair":"default",transform:`scale(${w})`,transformOrigin:"center center"}})]})]})}),{displayName:"NiceImageEditor"}),Wi={strokeColor:"#ff3333",fillColor:"transparent",strokeWidth:2,opacity:1,fontSize:16,fontFamily:"sans-serif"};function Ji(t,i){switch(i.type){case"SET_TOOL":return{...t,activeTool:i.tool,selectedId:null};case"SET_STYLE":return{...t,style:{...t.style,...i.style}};case"ADD_ANNOTATION":return{...t,annotations:[...t.annotations,i.annotation],past:[...t.past,t.annotations],future:[]};case"UPDATE_ANNOTATION":return{...t,annotations:t.annotations.map(o=>o.id===i.id?{...o,...i.updates}:o),past:[...t.past,t.annotations],future:[]};case"DELETE_ANNOTATION":return{...t,annotations:t.annotations.filter(o=>o.id!==i.id),selectedId:t.selectedId===i.id?null:t.selectedId,past:[...t.past,t.annotations],future:[]};case"SELECT":return{...t,selectedId:i.id};case"SET_ANNOTATIONS":return{...t,annotations:i.annotations,past:[],future:[]};case"SET_ZOOM":return{...t,zoom:i.zoom};case"SET_PAN":return{...t,panX:i.panX,panY:i.panY};case"UNDO":{if(t.past.length===0)return t;const o=t.past[t.past.length-1];return{...t,annotations:o,past:t.past.slice(0,-1),future:[t.annotations,...t.future]}}case"REDO":{if(t.future.length===0)return t;const o=t.future[0];return{...t,annotations:o,past:[...t.past,t.annotations],future:t.future.slice(1)}}case"CLEAR":return{...t,annotations:[],selectedId:null,past:[...t.past,t.annotations],future:[]};default:return t}}let Zi=0;function Qi(){return`ann-${Date.now()}-${Zi++}`}function eo(t){const{style:i}=t,o=`stroke="${i.strokeColor}" stroke-width="${i.strokeWidth}" fill="${i.fillColor}" opacity="${i.opacity}"`;switch(t.tool){case"rectangle":return`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" ${o} />`;case"ellipse":{const a=t.x+t.width/2,s=t.y+t.height/2;return`<ellipse cx="${a}" cy="${s}" rx="${t.width/2}" ry="${t.height/2}" ${o} />`}case"arrow":{const a=t,s=Math.atan2(a.endY-a.y,a.endX-a.x),g=12,x=a.endX-g*Math.cos(s-Math.PI/6),$=a.endY-g*Math.sin(s-Math.PI/6),P=a.endX-g*Math.cos(s+Math.PI/6),M=a.endY-g*Math.sin(s+Math.PI/6);return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />
|
|
302
|
+
<polygon points="${a.endX},${a.endY} ${x},${$} ${P},${M}" fill="${i.strokeColor}" opacity="${i.opacity}" />`}case"line":{const a=t;return`<line x1="${a.x}" y1="${a.y}" x2="${a.endX}" y2="${a.endY}" ${o} />`}case"text":{const a=t;return`<text x="${a.x}" y="${a.y+(a.style.fontSize??16)}" fill="${i.strokeColor}" font-size="${i.fontSize}" font-family="${i.fontFamily}" opacity="${i.opacity}">${to(a.text)}</text>`}case"freehand":{const a=t;return a.points.length<2?"":`<path d="${a.points.map((g,x)=>`${x===0?"M":"L"}${g.x},${g.y}`).join(" ")}" ${o} fill="none" />`}case"blur":{const a=t,s=`blur-${a.id}`;return`<defs><filter id="${s}"><feGaussianBlur stdDeviation="${a.intensity??5}" /></filter></defs>
|
|
303
|
+
<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" fill="transparent" stroke="none" filter="url(#${s})" />`}default:return""}}function to(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const no=Object.assign(n.forwardRef(({src:t,alt:i,annotations:o,activeTool:a,defaultStyle:s,onAnnotationsChange:g,className:x,readOnly:$=!1,minZoom:P=.1,maxZoom:M=5},W)=>{const{t:J}=r.useNiceTranslation(),B=i??J("imageAnnotator.annotatableImage","Annotatable image"),I=n.useRef(null),q=n.useRef(null),se=n.useRef(null),[oe,ce]=n.useState(!1),[Z,F]=n.useState({width:0,height:0}),[k,l]=n.useReducer(Ji,{annotations:o??[],selectedId:null,activeTool:a??"select",style:{...Wi,...s},zoom:1,panX:0,panY:0,past:[],future:[]});n.useEffect(()=>{a&&l({type:"SET_TOOL",tool:a})},[a]),n.useEffect(()=>{g?.(k.annotations)},[k.annotations,g]),n.useEffect(()=>{const w=new Image;w.crossOrigin="anonymous",w.onload=()=>{se.current=w,F({width:w.naturalWidth,height:w.naturalHeight}),ce(!0)},w.src=t},[t]);const T=n.useRef({isDrawing:!1,startX:0,startY:0,currentAnnotation:null,freehandPoints:[]}),Y=n.useCallback((w,d)=>{const D=I.current;if(!D)return{x:0,y:0};const j=D.getBoundingClientRect();return{x:(w-j.left-k.panX)/k.zoom,y:(d-j.top-k.panY)/k.zoom}},[k.zoom,k.panX,k.panY]),A=n.useCallback(()=>{const w=I.current,d=w?.getContext("2d"),D=se.current;if(!w||!d||!D||!oe)return;w.width=q.current?.clientWidth??D.naturalWidth,w.height=q.current?.clientHeight??D.naturalHeight,d.clearRect(0,0,w.width,w.height),d.save(),d.translate(k.panX,k.panY),d.scale(k.zoom,k.zoom),d.drawImage(D,0,0);for(const h of k.annotations){switch(d.save(),d.globalAlpha=h.style.opacity,d.strokeStyle=h.style.strokeColor,d.fillStyle=h.style.fillColor,d.lineWidth=h.style.strokeWidth,h.tool){case"rectangle":d.strokeRect(h.x,h.y,h.width,h.height),h.style.fillColor!=="transparent"&&d.fillRect(h.x,h.y,h.width,h.height);break;case"ellipse":{d.beginPath(),d.ellipse(h.x+h.width/2,h.y+h.height/2,Math.abs(h.width/2),Math.abs(h.height/2),0,0,Math.PI*2),d.stroke(),h.style.fillColor!=="transparent"&&d.fill();break}case"arrow":{const c=h;d.beginPath(),d.moveTo(c.x,c.y),d.lineTo(c.endX,c.endY),d.stroke();const p=Math.atan2(c.endY-c.y,c.endX-c.x),E=12;d.beginPath(),d.moveTo(c.endX,c.endY),d.lineTo(c.endX-E*Math.cos(p-Math.PI/6),c.endY-E*Math.sin(p-Math.PI/6)),d.lineTo(c.endX-E*Math.cos(p+Math.PI/6),c.endY-E*Math.sin(p+Math.PI/6)),d.closePath(),d.fillStyle=h.style.strokeColor,d.fill();break}case"line":{const c=h;d.beginPath(),d.moveTo(c.x,c.y),d.lineTo(c.endX,c.endY),d.stroke();break}case"text":{const c=h;d.font=`${c.style.fontSize??16}px ${c.style.fontFamily??"sans-serif"}`,d.fillStyle=c.style.strokeColor,d.fillText(c.text,c.x,c.y+(c.style.fontSize??16));break}case"freehand":{const c=h;if(c.points.length<2)break;d.beginPath(),d.moveTo(c.points[0].x,c.points[0].y);for(let p=1;p<c.points.length;p++)d.lineTo(c.points[p].x,c.points[p].y);d.stroke();break}case"blur":{const c=h;d.filter=`blur(${c.intensity??5}px)`,d.drawImage(D,c.x,c.y,c.width,c.height,c.x,c.y,c.width,c.height),d.filter="none";break}}h.id===k.selectedId&&(d.strokeStyle=r.resolveCssColor("var(--nice-color-primary, #4488ff)",d.canvas),d.lineWidth=1,d.setLineDash([4,4]),d.strokeRect(h.x-2,h.y-2,h.width+4,h.height+4),d.setLineDash([])),d.restore()}const j=T.current;if(j.isDrawing&&j.currentAnnotation){d.save();const h=j.currentAnnotation;if(d.globalAlpha=h.style.opacity,d.strokeStyle=h.style.strokeColor,d.lineWidth=h.style.strokeWidth,d.setLineDash([6,3]),h.tool==="freehand"){const c=h;if(c.points.length>=2){d.beginPath(),d.moveTo(c.points[0].x,c.points[0].y);for(let p=1;p<c.points.length;p++)d.lineTo(c.points[p].x,c.points[p].y);d.stroke()}}else if(h.tool==="rectangle")d.strokeRect(h.x,h.y,h.width,h.height);else if(h.tool==="ellipse")d.beginPath(),d.ellipse(h.x+h.width/2,h.y+h.height/2,Math.abs(h.width/2),Math.abs(h.height/2),0,0,Math.PI*2),d.stroke();else if(h.tool==="arrow"||h.tool==="line"){const c=h;d.beginPath(),d.moveTo(c.x,c.y),d.lineTo(c.endX,c.endY),d.stroke()}d.restore()}d.restore()},[k,oe]);n.useEffect(()=>{A()},[A]);const _=n.useCallback(w=>{if($)return;const d=Y(w.clientX,w.clientY),D=k.activeTool;if(D==="select"){const c=[...k.annotations].reverse().find(p=>p.tool==="freehand"?!1:d.x>=p.x&&d.x<=p.x+p.width&&d.y>=p.y&&d.y<=p.y+p.height);l({type:"SELECT",id:c?.id??null});return}const j=T.current;j.isDrawing=!0,j.startX=d.x,j.startY=d.y;const h={id:Qi(),style:{...k.style},x:d.x,y:d.y,width:0,height:0};switch(D){case"rectangle":j.currentAnnotation={...h,tool:"rectangle"};break;case"ellipse":j.currentAnnotation={...h,tool:"ellipse"};break;case"arrow":j.currentAnnotation={...h,tool:"arrow",endX:d.x,endY:d.y};break;case"line":j.currentAnnotation={...h,tool:"line",endX:d.x,endY:d.y};break;case"text":j.currentAnnotation={...h,tool:"text",text:J("imageAnnotator.text","Text"),width:100,height:k.style.fontSize??16};break;case"freehand":j.freehandPoints=[d],j.currentAnnotation={...h,tool:"freehand",points:[d]};break;case"blur":j.currentAnnotation={...h,tool:"blur",intensity:5};break}},[$,Y,k.activeTool,k.style,k.annotations,J]),b=n.useCallback(w=>{const d=T.current;if(!d.isDrawing||!d.currentAnnotation)return;const D=Y(w.clientX,w.clientY),j=d.currentAnnotation;if(j.tool==="freehand"){d.freehandPoints.push(D),j.points=[...d.freehandPoints];const h=d.freehandPoints.map(p=>p.x),c=d.freehandPoints.map(p=>p.y);j.x=Math.min(...h),j.y=Math.min(...c),j.width=Math.max(...h)-j.x,j.height=Math.max(...c)-j.y}else if(j.tool==="arrow"||j.tool==="line")j.endX=D.x,j.endY=D.y,j.width=Math.abs(D.x-d.startX),j.height=Math.abs(D.y-d.startY);else{const h=Math.min(d.startX,D.x),c=Math.min(d.startY,D.y);j.x=h,j.y=c,j.width=Math.abs(D.x-d.startX),j.height=Math.abs(D.y-d.startY)}A()},[Y,A]),C=n.useCallback(()=>{const w=T.current;if(!w.isDrawing||!w.currentAnnotation)return;const d=w.currentAnnotation;(d.tool==="text"||d.tool==="freehand"||Math.abs(d.width)>2||Math.abs(d.height)>2)&&l({type:"ADD_ANNOTATION",annotation:d}),w.isDrawing=!1,w.currentAnnotation=null,w.freehandPoints=[]},[]),f=n.useCallback(w=>{w.preventDefault();const d=w.deltaY>0?.9:1.1,D=Math.max(P,Math.min(M,k.zoom*d));l({type:"SET_ZOOM",zoom:D})},[k.zoom,P,M]);n.useEffect(()=>{if($)return;const w=d=>{(d.metaKey||d.ctrlKey)&&d.key==="z"&&!d.shiftKey?(d.preventDefault(),l({type:"UNDO"})):(d.metaKey||d.ctrlKey)&&(d.key==="y"||d.key==="z"&&d.shiftKey)?(d.preventDefault(),l({type:"REDO"})):(d.key==="Delete"||d.key==="Backspace")&&k.selectedId&&l({type:"DELETE_ANNOTATION",id:k.selectedId})};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[$,k.selectedId]),n.useImperativeHandle(W,()=>({exportAsDataURL:async(w="png",d=.92)=>{const D=document.createElement("canvas"),j=se.current;if(!j)return"";D.width=j.naturalWidth,D.height=j.naturalHeight;const h=D.getContext("2d");h.drawImage(j,0,0);for(const c of k.annotations){if(h.save(),h.globalAlpha=c.style.opacity,h.strokeStyle=c.style.strokeColor,h.fillStyle=c.style.fillColor,h.lineWidth=c.style.strokeWidth,c.tool==="rectangle")h.strokeRect(c.x,c.y,c.width,c.height);else if(c.tool==="ellipse")h.beginPath(),h.ellipse(c.x+c.width/2,c.y+c.height/2,Math.abs(c.width/2),Math.abs(c.height/2),0,0,Math.PI*2),h.stroke();else if(c.tool==="freehand"){const p=c;if(p.points.length>=2){h.beginPath(),h.moveTo(p.points[0].x,p.points[0].y);for(let E=1;E<p.points.length;E++)h.lineTo(p.points[E].x,p.points[E].y);h.stroke()}}else if(c.tool==="text"){const p=c;h.font=`${p.style.fontSize??16}px ${p.style.fontFamily??"sans-serif"}`,h.fillStyle=p.style.strokeColor,h.fillText(p.text,p.x,p.y+(p.style.fontSize??16))}h.restore()}return D.toDataURL(`image/${w}`,d)},exportAnnotations:()=>[...k.annotations],importAnnotations:w=>{l({type:"SET_ANNOTATIONS",annotations:w})},exportAsSVG:()=>{const{width:w,height:d}=Z,D=k.annotations.map(eo);return`<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${d}" viewBox="0 0 ${w} ${d}">
|
|
304
304
|
${D.join(`
|
|
305
305
|
`)}
|
|
306
|
-
</svg>`},undo:()=>l({type:"UNDO"}),redo:()=>l({type:"REDO"}),setZoom:w=>{l({type:"SET_ZOOM",zoom:Math.max(P,Math.min(M,w))})},fitToScreen:()=>{const w=X.current,d=se.current;if(!w||!d)return;const D=w.clientWidth/d.naturalWidth,j=w.clientHeight/d.naturalHeight,h=Math.min(D,j,1);l({type:"SET_ZOOM",zoom:h}),l({type:"SET_PAN",panX:0,panY:0})},clear:()=>l({type:"CLEAR"})}),[k.annotations,Z,P,M]);const S=n.useCallback(w=>{if(w.touches.length!==1)return;const d=w.touches[0];_({clientX:d.clientX,clientY:d.clientY,preventDefault:()=>{}})},[_]),K=n.useCallback(w=>{if(w.touches.length!==1)return;const d=w.touches[0];b({clientX:d.clientX,clientY:d.clientY})},[b]);return e.jsx("div",{ref:X,className:`nice-image-annotator ${x??""}`,children:e.jsx("canvas",{ref:I,className:"nice-image-annotator__canvas",style:{cursor:k.activeTool==="select"?"default":"crosshair"},onMouseDown:_,onMouseMove:b,onMouseUp:C,onMouseLeave:C,onWheel:f,onTouchStart:S,onTouchMove:K,onTouchEnd:C,role:"img","aria-label":B})})}),{displayName:"NiceImageAnnotator"}),oo=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],Sn=[{label:"Free",value:"free"},{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"3:4",value:"3:4",ratio:3/4},{label:"16:9",value:"16:9",ratio:16/9},{label:"9:16",value:"9:16",ratio:9/16},{label:"3:2",value:"3:2",ratio:3/2},{label:"2:3",value:"2:3",ratio:2/3}],En=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:a=1,aspectRatios:s=Sn,defaultAspectRatio:g="free",customAspectRatio:x,showRotation:$=!0,showFlip:P=!0,showZoom:M=!0,minZoom:W=.5,maxZoom:J=3,zoomStep:B=.1,showGrid:I=!0,overlayColor:X="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:se="bottom",toolbarCollapsible:oe=!1,defaultToolbarCollapsed:ce=!1,onChange:Z,tutorial:F,className:k="",style:l,"data-testid":T="nice-crop-editor"})=>{const{t:Y}=r.useNiceTranslation(),A=n.useRef(null),_=n.useRef(null),[b,C]=n.useState(i),[f,S]=n.useState(o),[K,w]=n.useState(a),[d,D]=n.useState(!1),[j,h]=n.useState(!1),[c,p]=n.useState(g),[E,N]=n.useState(ce),[m,R]=n.useState(!1),[z,ie]=n.useState({x:0,y:0,crop:b}),v=c==="custom"?x:s.find(te=>te.value===c)?.ratio;n.useEffect(()=>{Z?.({crop:b,rotation:f,flipH:d,flipV:j,zoom:K})},[b,f,d,j,K,Z]);const ee=n.useCallback((te,we)=>{if(!v)return te;const re=A.current?.clientWidth??400,fe=A.current?.clientHeight??300,H=te.width/100*re,q=te.height/100*fe,O=H/q;if(Math.abs(O-v)<.01)return te;if(we?.includes("e")||we?.includes("w")){const G=H/v/fe*100;return{...te,height:Math.min(100-te.y,Math.max(5,G))}}else if(we?.includes("n")||we?.includes("s")){const G=q*v/re*100;return{...te,width:Math.min(100-te.x,Math.max(5,G))}}else{const G=H/v/fe*100;return{...te,height:Math.min(100-te.y,Math.max(5,G))}}},[v]),U=n.useCallback((te,we)=>{we===!1||(te.preventDefault(),te.stopPropagation(),R(we),!A.current?.getBoundingClientRect())||ie({x:te.clientX,y:te.clientY,crop:{...b}})},[b]),me=n.useCallback(te=>{if(!m||!A.current)return;const we=A.current.getBoundingClientRect(),re=(te.clientX-z.x)/we.width*100,fe=(te.clientY-z.y)/we.height*100;let H={...z.crop};if(m==="crop")H.x=Math.max(0,Math.min(100-H.width,z.crop.x+re)),H.y=Math.max(0,Math.min(100-H.height,z.crop.y+fe));else{switch(m){case"resize-nw":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.width=z.crop.width-(H.x-z.crop.x),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-ne":H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re)),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-sw":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.width=z.crop.width-(H.x-z.crop.x),H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-se":H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re)),H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-n":H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-s":H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-e":H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re));break;case"resize-w":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.width=z.crop.width-(H.x-z.crop.x);break}H=ee(H,m.replace("resize-",""))}C(H)},[m,z,ee]),pe=n.useCallback(()=>{R(!1)},[]);n.useEffect(()=>{if(m)return document.addEventListener("mousemove",me),document.addEventListener("mouseup",pe),()=>{document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",pe)}},[m,me,pe]);const ye=n.useCallback(()=>{S(te=>(te-90+360)%360)},[]),ue=n.useCallback(()=>{S(te=>(te+90)%360)},[]),he=n.useCallback(()=>{D(te=>!te)},[]),de=n.useCallback(()=>{h(te=>!te)},[]),ge=n.useCallback(()=>{C(i),S(o),w(a),D(!1),h(!1),p(g)},[i,o,a,g]);n.useEffect(()=>{C(te=>ee(te))},[c,ee]);const ae=`translate(-50%, -50%) scale(${K}) rotate(${f}deg) scaleX(${d?-1:1}) scaleY(${j?-1:1})`,ve=se==="top"?"column-reverse":se==="left"?"row-reverse":se==="right"?"row":"column",_e=se==="left"||se==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${se} ${k}`,style:{position:"relative",display:"flex",flexDirection:ve,gap:12,...l},"data-testid":T,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(F,oo)})}),e.jsxs("div",{ref:A,className:"nice-crop-editor__container","data-testid":`${T}-container`,children:[e.jsx("img",{ref:_,src:t||void 0,alt:"",className:"nice-crop-editor__image",style:{transform:ae},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:X},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${b.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-b.y-b.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${b.y}%`,left:0,width:`${b.x}%`,height:`${b.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${b.y}%`,right:0,width:`${100-b.x-b.width}%`,height:`${b.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${b.x}%`,top:`${b.y}%`,width:`${b.width}%`,height:`${b.height}%`},onMouseDown:te=>U(te,"crop"),"data-testid":`${T}-crop-area`,children:[I&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:te=>U(te,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:te=>U(te,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:te=>U(te,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:te=>U(te,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:te=>U(te,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:te=>U(te,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:te=>U(te,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:te=>U(te,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${E?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:_e?"column":"row",flexWrap:_e?"nowrap":"wrap",gap:8,alignItems:_e?"stretch":"center",flexShrink:0},children:[oe&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!E,"aria-label":E?Y("cropEditor.showToolbar","Show toolbar"):Y("cropEditor.hideToolbar","Hide toolbar"),onClick:()=>N(te=>!te),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(r.NiceIcon,{name:E?"chevron-right":"chevron-down",size:14})}),!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:Y("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:s.map(te=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${c===te.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>p(te.value),title:te.label,children:te.label},te.value))})]}),M&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[Y("zoom","Zoom"),": ",Math.round(K*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:W,max:J,step:B,value:K,onChange:te=>w(parseFloat(te.target.value)),"data-testid":`${T}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[$&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ye,title:Y("rotateLeft","Rotate Left"),"aria-label":Y("rotateLeft","Rotate Left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ue,title:Y("rotateRight","Rotate Right"),"aria-label":Y("rotateRight","Rotate Right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${d?"nice-crop-editor__btn--active":""}`,onClick:he,title:Y("flipHorizontal","Flip Horizontal"),"aria-label":Y("flipHorizontal","Flip Horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${j?"nice-crop-editor__btn--active":""}`,onClick:de,title:Y("flipVertical","Flip Vertical"),"aria-label":Y("flipVertical","Flip Vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:ge,title:Y("reset","Reset"),"aria-label":Y("reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]})]})]})]})};process.env.NODE_ENV!=="production"&&(En.displayName="NiceCropEditor");const ao=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],so=["highlight","underline","strikethrough","freehand","text","rect","arrow"],ro={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},co=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",id:$,className:P,style:M,accessMode:W,src:J,annotations:B=[],onAnnotationsChange:I,activeTool:X,onToolChange:se,currentPage:oe=1,onPageChange:ce,totalPages:Z=1,defaultColor:F="var(--nice-warning, #ffff00)",tools:k=so,author:l,zoom:T=1,onZoomChange:Y,onAnnotationClick:A,onAnnotationDelete:_,tutorial:b},C)=>{const f=r.useNiceAccessMode(W,$),S=f==="hidden";f==="disabled"&&(s=!0),f==="readOnly"&&(g=!0);const{t:K}=r.useNiceTranslation(),w=r.useControlId($),d=B.filter(m=>m.page===oe),D=n.useCallback(m=>{se?.(X===m?null:m)},[X,se]),j=n.useCallback(m=>{if(g||!X||X==="freehand")return;const R=m.currentTarget.getBoundingClientRect(),z=(m.clientX-R.left)/R.width,ie=(m.clientY-R.top)/R.height,v={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:X,page:oe,x:z,y:ie,color:F,author:l,createdAt:new Date().toISOString(),text:X==="text"?"":void 0};I?.([...B,v])},[g,X,oe,F,l,B,I]);if(S)return null;const h=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,c=g?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[k.map(m=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${X===m?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>D(m),disabled:s,title:K(`pdfTool_${m}`,m),children:e.jsx(r.NiceIcon,{name:ro[m],size:16})},m)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:s,onClick:()=>Y?.(Math.max(.25,T-.25)),title:K("zoomOut","Zoom out"),"aria-label":K("zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(T*100),"%"]}),e.jsx("button",{type:"button",disabled:s,onClick:()=>Y?.(Math.min(4,T+.25)),title:K("zoomIn","Zoom in"),"aria-label":K("zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})})]}),p=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:s||oe<=1,onClick:()=>ce?.(oe-1),"aria-label":K("prevPage","Previous page"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("span",{children:K("pageOf","{page} / {total}").replace("{page}",String(oe)).replace("{total}",String(Z))}),e.jsx("button",{type:"button",disabled:s||oe>=Z,onClick:()=>ce?.(oe+1),"aria-label":K("nextPage","Next page"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:16})})]}),N=!!i||!!o&&typeof o=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]}):void 0;return e.jsx(tt.NiceAppShell,{ref:C,flush:!0,id:w,className:`nice-pdf-annotation nice-size-${x}${P?` ${P}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:M,menubar:h,toolbar:c,bottomPanel:p,statusBar:N,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"auto"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(b,ao)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${T})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:J||void 0,className:"nice-pdf-annotation__frame",title:K("pdfViewer","PDF Viewer")}),e.jsx("div",{role:"presentation",className:"nice-pdf-annotation__layer",onClick:j,children:d.map(m=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${m.tool}`,style:{left:`${m.x*100}%`,top:`${m.y*100}%`,backgroundColor:m.color},onClick:R=>{R.stopPropagation(),A?.(m)},title:m.text??m.tool,children:[m.text&&e.jsx("span",{children:m.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:R=>{R.stopPropagation(),_?.(m.id)},"aria-label":K("delete","Delete"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},m.id))})]})]})})}),{displayName:"NicePDFAnnotationEditor"});function nn(t,i){const o=i.getBoundingClientRect();let a,s,g;if("touches"in t){const x=t.touches[0];a=x.clientX-o.left,s=x.clientY-o.top,g=x.force}else"pressure"in t?(a=t.clientX-o.left,s=t.clientY-o.top,g=t.pressure):(a=t.clientX-o.left,s=t.clientY-o.top);return{x:a,y:s,time:Date.now(),pressure:g!==void 0?g:.5}}function on(t,i,o,a,s){if(!i)return(o+a)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),x=Math.min(g/5,1),$=a-x*(a-o),P=t.pressure??.5,M=o+P*(a-o);return $*.7+M*.3}function an(t,i,o,a){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(o.x,o.y),t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.stroke()}const lo=n.forwardRef(function(i,o){wt.injectStyleOnce(mo,uo);const{value:a,onChange:s,onChangeDataUrl:g,label:x,width:$="100%",height:P=200,penColor:M="",penWidth:W=2,minWidth:J=.5,maxWidth:B=4,backgroundColor:I="",placeholder:X,showClearButton:se=!0,showUndoButton:oe=!0,showColorPicker:ce=!1,showSizeSlider:Z=!1,velocityFilterWeight:F=.7,throttle:k=16,disabled:l=!1,readOnly:T=!1,displayMode:Y=!1,onBegin:A,onEnd:_,className:b,"data-testid":C}=i,{t:f}=r.useNiceTranslation(),S=X||f("signature.placeholder","Sign here"),K=T||Y,w=Y?!1:se,d=Y?!1:oe,D=Y?!1:ce,j=Y?!1:Z,h=n.useRef(null),[c,p]=n.useState(a?.strokes??[]),[E,N]=n.useState([]),[m,R]=n.useState(!1),[z,ie]=n.useState(M),[v,ee]=n.useState(W),U=n.useRef(null),me=n.useRef(0),pe=r.useThemeIsDark(h),ye=I||(pe?"#0f172a":"#ffffff"),ue=M||(pe?"#f8fafc":"#111827"),he=z||ue,de=c.length===0&&E.length===0;n.useEffect(()=>{const O=h.current;if(!O)return;const y=O.getContext("2d");if(!y)return;const G=O.getBoundingClientRect(),ne=window.devicePixelRatio||1;O.width=G.width*ne,O.height=G.height*ne,y.scale(ne,ne),ge()},[$,P]);const ge=n.useCallback(()=>{const O=h.current;if(!O)return;const y=O.getContext("2d");if(!y)return;const G=O.getBoundingClientRect();y.fillStyle=ye,y.fillRect(0,0,G.width,G.height),c.forEach(ne=>{if(y.strokeStyle=ne.color||ue,!(ne.points.length<2))for(let le=1;le<ne.points.length;le++){const be=ne.points[le-1],xe=ne.points[le],Se=on(xe,be,J,B);an(y,be,xe,Se)}})},[c,ye,ue,J,B,F]);n.useEffect(()=>{ge()},[ge]),n.useEffect(()=>{a?.strokes&&p(a.strokes)},[a]),n.useEffect(()=>{const O=h.current;if(O)if(c.length===0)s?.(null),g?.(null);else{const y=O.getBoundingClientRect();s?.({strokes:c,width:y.width,height:y.height,timestamp:Date.now()}),g?.(O.toDataURL("image/png"))}},[c,s,g]);const ae=n.useCallback(O=>{if(l||K)return;const y=h.current;if(!y)return;y.setPointerCapture(O.pointerId);const G=nn(O.nativeEvent,y);R(!0),N([G]),U.current=G,me.current=G.time,A?.()},[l,K,A]),ve=n.useCallback(O=>{if(!m||l||K)return;const y=h.current;if(!y)return;const G=y.getContext("2d");if(!G)return;const ne=Date.now();if(ne-me.current<k)return;const le=nn(O.nativeEvent,y),be=U.current;if(be){G.strokeStyle=he;const xe=on(le,be,J,B);an(G,be,le,xe)}N(xe=>[...xe,le]),U.current=le,me.current=ne},[m,l,K,he,J,B,F,k]),_e=n.useCallback(O=>{if(!m)return;const y=h.current;if(y&&y.releasePointerCapture(O.pointerId),E.length>0){const G={points:E,color:he,width:v};p(ne=>[...ne,G])}R(!1),N([]),U.current=null,_?.()},[m,E,he,v,_]),te=n.useCallback(()=>{p([]),N([]),ge()},[ge]),we=n.useCallback(()=>{p(O=>O.slice(0,-1))},[]),re=n.useCallback((O="png",y=.92)=>{const G=h.current;if(!G)return"";const ne=O==="jpeg"?"image/jpeg":"image/png";return G.toDataURL(ne,y)},[]),fe=n.useCallback(async(O="png",y=.92)=>{const G=h.current;return G?new Promise(ne=>{const le=O==="jpeg"?"image/jpeg":"image/png";G.toBlob(be=>ne(be),le,y)}):null},[]),H=n.useCallback(()=>{const O=h.current;if(!O)return"";const y=O.getBoundingClientRect(),G=c.map(ne=>ne.points.length<2?"":`<path d="${ne.points.reduce((be,xe,Se)=>Se===0?`M ${xe.x} ${xe.y}`:`${be} L ${xe.x} ${xe.y}`,"")}" stroke="${ne.color||ue}" stroke-width="${ne.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
306
|
+
</svg>`},undo:()=>l({type:"UNDO"}),redo:()=>l({type:"REDO"}),setZoom:w=>{l({type:"SET_ZOOM",zoom:Math.max(P,Math.min(M,w))})},fitToScreen:()=>{const w=q.current,d=se.current;if(!w||!d)return;const D=w.clientWidth/d.naturalWidth,j=w.clientHeight/d.naturalHeight,h=Math.min(D,j,1);l({type:"SET_ZOOM",zoom:h}),l({type:"SET_PAN",panX:0,panY:0})},clear:()=>l({type:"CLEAR"})}),[k.annotations,Z,P,M]);const S=n.useCallback(w=>{if(w.touches.length!==1)return;const d=w.touches[0];_({clientX:d.clientX,clientY:d.clientY,preventDefault:()=>{}})},[_]),K=n.useCallback(w=>{if(w.touches.length!==1)return;const d=w.touches[0];b({clientX:d.clientX,clientY:d.clientY})},[b]);return e.jsx("div",{ref:q,className:`nice-image-annotator ${x??""}`,children:e.jsx("canvas",{ref:I,className:"nice-image-annotator__canvas",style:{cursor:k.activeTool==="select"?"default":"crosshair"},onMouseDown:_,onMouseMove:b,onMouseUp:C,onMouseLeave:C,onWheel:f,onTouchStart:S,onTouchMove:K,onTouchEnd:C,role:"img","aria-label":B})})}),{displayName:"NiceImageAnnotator"}),io=[{target:".nice-crop-editor",titleKey:"tutorial.cropEditor.intro.title",title:"Crop editor",contentKey:"tutorial.cropEditor.intro.content",content:"Drag the crop box over the image, pick an aspect ratio, rotate, flip or zoom, then use the result.",placement:"auto"}],Cn=[{label:"Free",value:"free"},{label:"1:1",value:"1:1",ratio:1},{label:"4:3",value:"4:3",ratio:4/3},{label:"3:4",value:"3:4",ratio:3/4},{label:"16:9",value:"16:9",ratio:16/9},{label:"9:16",value:"9:16",ratio:9/16},{label:"3:2",value:"3:2",ratio:3/2},{label:"2:3",value:"2:3",ratio:2/3}],Sn=({src:t,initialCrop:i={x:10,y:10,width:80,height:80},initialRotation:o=0,initialZoom:a=1,aspectRatios:s=Cn,defaultAspectRatio:g="free",customAspectRatio:x,showRotation:$=!0,showFlip:P=!0,showZoom:M=!0,minZoom:W=.5,maxZoom:J=3,zoomStep:B=.1,showGrid:I=!0,overlayColor:q="var(--nice-overlay-50, rgba(0, 0, 0, 0.5))",toolbarPosition:se="bottom",toolbarCollapsible:oe=!1,defaultToolbarCollapsed:ce=!1,onChange:Z,tutorial:F,className:k="",style:l,"data-testid":T="nice-crop-editor"})=>{const{t:Y}=r.useNiceTranslation(),A=n.useRef(null),_=n.useRef(null),[b,C]=n.useState(i),[f,S]=n.useState(o),[K,w]=n.useState(a),[d,D]=n.useState(!1),[j,h]=n.useState(!1),[c,p]=n.useState(g),[E,N]=n.useState(ce),[m,R]=n.useState(!1),[z,ie]=n.useState({x:0,y:0,crop:b}),v=c==="custom"?x:s.find(te=>te.value===c)?.ratio;n.useEffect(()=>{Z?.({crop:b,rotation:f,flipH:d,flipV:j,zoom:K})},[b,f,d,j,K,Z]);const ee=n.useCallback((te,we)=>{if(!v)return te;const re=A.current?.clientWidth??400,fe=A.current?.clientHeight??300,H=te.width/100*re,X=te.height/100*fe,O=H/X;if(Math.abs(O-v)<.01)return te;if(we?.includes("e")||we?.includes("w")){const G=H/v/fe*100;return{...te,height:Math.min(100-te.y,Math.max(5,G))}}else if(we?.includes("n")||we?.includes("s")){const G=X*v/re*100;return{...te,width:Math.min(100-te.x,Math.max(5,G))}}else{const G=H/v/fe*100;return{...te,height:Math.min(100-te.y,Math.max(5,G))}}},[v]),U=n.useCallback((te,we)=>{we===!1||(te.preventDefault(),te.stopPropagation(),R(we),!A.current?.getBoundingClientRect())||ie({x:te.clientX,y:te.clientY,crop:{...b}})},[b]),me=n.useCallback(te=>{if(!m||!A.current)return;const we=A.current.getBoundingClientRect(),re=(te.clientX-z.x)/we.width*100,fe=(te.clientY-z.y)/we.height*100;let H={...z.crop};if(m==="crop")H.x=Math.max(0,Math.min(100-H.width,z.crop.x+re)),H.y=Math.max(0,Math.min(100-H.height,z.crop.y+fe));else{switch(m){case"resize-nw":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.width=z.crop.width-(H.x-z.crop.x),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-ne":H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re)),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-sw":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.width=z.crop.width-(H.x-z.crop.x),H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-se":H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re)),H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-n":H.y=Math.max(0,Math.min(z.crop.y+z.crop.height-5,z.crop.y+fe)),H.height=z.crop.height-(H.y-z.crop.y);break;case"resize-s":H.height=Math.max(5,Math.min(100-H.y,z.crop.height+fe));break;case"resize-e":H.width=Math.max(5,Math.min(100-H.x,z.crop.width+re));break;case"resize-w":H.x=Math.max(0,Math.min(z.crop.x+z.crop.width-5,z.crop.x+re)),H.width=z.crop.width-(H.x-z.crop.x);break}H=ee(H,m.replace("resize-",""))}C(H)},[m,z,ee]),pe=n.useCallback(()=>{R(!1)},[]);n.useEffect(()=>{if(m)return document.addEventListener("mousemove",me),document.addEventListener("mouseup",pe),()=>{document.removeEventListener("mousemove",me),document.removeEventListener("mouseup",pe)}},[m,me,pe]);const ye=n.useCallback(()=>{S(te=>(te-90+360)%360)},[]),ue=n.useCallback(()=>{S(te=>(te+90)%360)},[]),he=n.useCallback(()=>{D(te=>!te)},[]),de=n.useCallback(()=>{h(te=>!te)},[]),ge=n.useCallback(()=>{C(i),S(o),w(a),D(!1),h(!1),p(g)},[i,o,a,g]);n.useEffect(()=>{C(te=>ee(te))},[c,ee]);const ae=`translate(-50%, -50%) scale(${K}) rotate(${f}deg) scaleX(${d?-1:1}) scaleY(${j?-1:1})`,ve=se==="top"?"column-reverse":se==="left"?"row-reverse":se==="right"?"row":"column",_e=se==="left"||se==="right";return e.jsxs("div",{className:`nice-crop-editor nice-crop-editor--toolbar-${se} ${k}`,style:{position:"relative",display:"flex",flexDirection:ve,gap:12,...l},"data-testid":T,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(F,io)})}),e.jsxs("div",{ref:A,className:"nice-crop-editor__container","data-testid":`${T}-container`,children:[e.jsx("img",{ref:_,src:t||void 0,alt:"",className:"nice-crop-editor__image",style:{transform:ae},draggable:!1}),e.jsxs("div",{className:"nice-crop-editor__overlay",style:{backgroundColor:q},children:[e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:0,left:0,right:0,height:`${b.y}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{bottom:0,left:0,right:0,height:`${100-b.y-b.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${b.y}%`,left:0,width:`${b.x}%`,height:`${b.height}%`}}),e.jsx("div",{className:"nice-crop-editor__overlay-piece",style:{top:`${b.y}%`,right:0,width:`${100-b.x-b.width}%`,height:`${b.height}%`}})]}),e.jsxs("div",{className:"nice-crop-editor__crop-area",style:{left:`${b.x}%`,top:`${b.y}%`,width:`${b.width}%`,height:`${b.height}%`},onMouseDown:te=>U(te,"crop"),"data-testid":`${T}-crop-area`,children:[I&&e.jsxs("div",{className:"nice-crop-editor__grid",children:[e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--h2"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v1"}),e.jsx("div",{className:"nice-crop-editor__grid-line nice-crop-editor__grid-line--v2"})]}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--nw",onMouseDown:te=>U(te,"resize-nw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--ne",onMouseDown:te=>U(te,"resize-ne")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--sw",onMouseDown:te=>U(te,"resize-sw")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--se",onMouseDown:te=>U(te,"resize-se")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--n",onMouseDown:te=>U(te,"resize-n")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--s",onMouseDown:te=>U(te,"resize-s")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--e",onMouseDown:te=>U(te,"resize-e")}),e.jsx("div",{className:"nice-crop-editor__handle nice-crop-editor__handle--w",onMouseDown:te=>U(te,"resize-w")})]})]}),e.jsxs("div",{className:`nice-crop-editor__controls ${E?"nice-crop-editor__controls--collapsed":""}`,style:{display:"flex",flexDirection:_e?"column":"row",flexWrap:_e?"nowrap":"wrap",gap:8,alignItems:_e?"stretch":"center",flexShrink:0},children:[oe&&e.jsx("button",{type:"button",className:"nice-crop-editor__toolbar-toggle","aria-expanded":!E,"aria-label":E?Y("cropEditor.showToolbar","Show toolbar"):Y("cropEditor.hideToolbar","Hide toolbar"),onClick:()=>N(te=>!te),style:{alignSelf:"flex-start",background:"var(--nice-bg-secondary)",border:"1px solid var(--nice-border-color)",borderRadius:4,padding:"2px 8px",cursor:"pointer",color:"var(--nice-text-primary)",fontSize:12},children:e.jsx(r.NiceIcon,{name:E?"chevron-right":"chevron-down",size:14})}),!E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsx("label",{className:"nice-crop-editor__label",children:Y("aspectRatio","Aspect Ratio")}),e.jsx("div",{className:"nice-crop-editor__aspect-buttons",children:s.map(te=>e.jsx("button",{type:"button",className:`nice-crop-editor__aspect-btn ${c===te.value?"nice-crop-editor__aspect-btn--selected":""}`,onClick:()=>p(te.value),title:te.label,children:te.label},te.value))})]}),M&&e.jsxs("div",{className:"nice-crop-editor__control-group",children:[e.jsxs("label",{className:"nice-crop-editor__label",children:[Y("zoom","Zoom"),": ",Math.round(K*100),"%"]}),e.jsx("input",{type:"range",className:"nice-crop-editor__slider",min:W,max:J,step:B,value:K,onChange:te=>w(parseFloat(te.target.value)),"data-testid":`${T}-zoom`})]}),e.jsxs("div",{className:"nice-crop-editor__control-group nice-crop-editor__control-group--row",children:[$&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ye,title:Y("rotateLeft","Rotate Left"),"aria-label":Y("rotateLeft","Rotate Left"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn",onClick:ue,title:Y("rotateRight","Rotate Right"),"aria-label":Y("rotateRight","Rotate Right"),children:e.jsx(r.NiceIcon,{name:"forward",size:16})})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${d?"nice-crop-editor__btn--active":""}`,onClick:he,title:Y("flipHorizontal","Flip Horizontal"),"aria-label":Y("flipHorizontal","Flip Horizontal"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})}),e.jsx("button",{type:"button",className:`nice-crop-editor__btn ${j?"nice-crop-editor__btn--active":""}`,onClick:de,title:Y("flipVertical","Flip Vertical"),"aria-label":Y("flipVertical","Flip Vertical"),children:e.jsx(r.NiceIcon,{name:"shuffle",size:16})})]}),e.jsx("button",{type:"button",className:"nice-crop-editor__btn nice-crop-editor__btn--reset",onClick:ge,title:Y("reset","Reset"),"aria-label":Y("reset","Reset"),children:e.jsx(r.NiceIcon,{name:"refresh",size:16})})]})]})]})]})};process.env.NODE_ENV!=="production"&&(Sn.displayName="NiceCropEditor");const oo=[{target:".nice-pdf-annotation",titleKey:"tutorial.pdfAnnotationEditor.intro.title",title:"PDF annotations",contentKey:"tutorial.pdfAnnotationEditor.intro.content",content:"Pick a tool from the toolbar (highlight, underline, freehand, text…), mark up the page, navigate pages and zoom as needed.",placement:"auto"}],ao=["highlight","underline","strikethrough","freehand","text","rect","arrow"],so={highlight:"edit",underline:"type",strikethrough:"type",freehand:"edit",text:"type",rect:"box",arrow:"arrow-right",stamp:"tag"},ro=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",id:$,className:P,style:M,accessMode:W,src:J,annotations:B=[],onAnnotationsChange:I,activeTool:q,onToolChange:se,currentPage:oe=1,onPageChange:ce,totalPages:Z=1,defaultColor:F="var(--nice-warning, #ffff00)",tools:k=ao,author:l,zoom:T=1,onZoomChange:Y,onAnnotationClick:A,onAnnotationDelete:_,tutorial:b},C)=>{const f=r.useNiceAccessMode(W,$),S=f==="hidden";f==="disabled"&&(s=!0),f==="readOnly"&&(g=!0);const{t:K}=r.useNiceTranslation(),w=r.useControlId($),d=B.filter(m=>m.page===oe),D=n.useCallback(m=>{se?.(q===m?null:m)},[q,se]),j=n.useCallback(m=>{if(g||!q||q==="freehand")return;const R=m.currentTarget.getBoundingClientRect(),z=(m.clientX-R.left)/R.width,ie=(m.clientY-R.top)/R.height,v={id:`ann-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,tool:q,page:oe,x:z,y:ie,color:F,author:l,createdAt:new Date().toISOString(),text:q==="text"?"":void 0};I?.([...B,v])},[g,q,oe,F,l,B,I]);if(S)return null;const h=t?e.jsxs("div",{className:"nice-pdf-annotation__label",children:[t,a&&e.jsx("span",{className:"nice-required",children:"*"})]}):void 0,c=g?void 0:e.jsxs("div",{className:"nice-pdf-annotation__toolbar",children:[k.map(m=>e.jsx("button",{type:"button",className:`nice-pdf-annotation__tool-btn${q===m?" nice-pdf-annotation__tool-btn--active":""}`,onClick:()=>D(m),disabled:s,title:K(`pdfTool_${m}`,m),children:e.jsx(r.NiceIcon,{name:so[m],size:16})},m)),e.jsx("span",{className:"nice-pdf-annotation__toolbar-sep"}),e.jsx("button",{type:"button",disabled:s,onClick:()=>Y?.(Math.max(.25,T-.25)),title:K("zoomOut","Zoom out"),"aria-label":K("zoomOut","Zoom out"),children:e.jsx(r.NiceIcon,{name:"minus",size:16})}),e.jsxs("span",{className:"nice-pdf-annotation__zoom",children:[Math.round(T*100),"%"]}),e.jsx("button",{type:"button",disabled:s,onClick:()=>Y?.(Math.min(4,T+.25)),title:K("zoomIn","Zoom in"),"aria-label":K("zoomIn","Zoom in"),children:e.jsx(r.NiceIcon,{name:"plus",size:16})})]}),p=e.jsxs("div",{className:"nice-pdf-annotation__pager",children:[e.jsx("button",{type:"button",disabled:s||oe<=1,onClick:()=>ce?.(oe-1),"aria-label":K("prevPage","Previous page"),children:e.jsx(r.NiceIcon,{name:"chevron-left",size:16})}),e.jsx("span",{children:K("pageOf","{page} / {total}").replace("{page}",String(oe)).replace("{total}",String(Z))}),e.jsx("button",{type:"button",disabled:s||oe>=Z,onClick:()=>ce?.(oe+1),"aria-label":K("nextPage","Next page"),children:e.jsx(r.NiceIcon,{name:"chevron-right",size:16})})]}),N=!!i||!!o&&typeof o=="string"?e.jsxs(e.Fragment,{children:[i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]}):void 0;return e.jsx(tt.NiceAppShell,{ref:C,flush:!0,id:w,className:`nice-pdf-annotation nice-size-${x}${P?` ${P}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:M,menubar:h,toolbar:c,bottomPanel:p,statusBar:N,children:e.jsxs("div",{style:{position:"relative",height:"100%",overflow:"auto"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(b,oo)})}),e.jsxs("div",{className:"nice-pdf-annotation__viewport",style:{transform:`scale(${T})`,transformOrigin:"top left"},children:[e.jsx("iframe",{src:J||void 0,className:"nice-pdf-annotation__frame",title:K("pdfViewer","PDF Viewer")}),e.jsx("div",{role:"presentation",className:"nice-pdf-annotation__layer",onClick:j,children:d.map(m=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:r.clickOnActivationKey,className:`nice-pdf-annotation__mark nice-pdf-annotation__mark--${m.tool}`,style:{left:`${m.x*100}%`,top:`${m.y*100}%`,backgroundColor:m.color},onClick:R=>{R.stopPropagation(),A?.(m)},title:m.text??m.tool,children:[m.text&&e.jsx("span",{children:m.text}),!g&&e.jsx("button",{type:"button",className:"nice-pdf-annotation__mark-delete",onClick:R=>{R.stopPropagation(),_?.(m.id)},"aria-label":K("delete","Delete"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})]},m.id))})]})]})})}),{displayName:"NicePDFAnnotationEditor"});function tn(t,i){const o=i.getBoundingClientRect();let a,s,g;if("touches"in t){const x=t.touches[0];a=x.clientX-o.left,s=x.clientY-o.top,g=x.force}else"pressure"in t?(a=t.clientX-o.left,s=t.clientY-o.top,g=t.pressure):(a=t.clientX-o.left,s=t.clientY-o.top);return{x:a,y:s,time:Date.now(),pressure:g!==void 0?g:.5}}function nn(t,i,o,a,s){if(!i)return(o+a)/2;const g=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2))/Math.max(1,t.time-i.time),x=Math.min(g/5,1),$=a-x*(a-o),P=t.pressure??.5,M=o+P*(a-o);return $*.7+M*.3}function on(t,i,o,a){t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(o.x,o.y),t.lineWidth=a,t.lineCap="round",t.lineJoin="round",t.stroke()}const co=n.forwardRef(function(i,o){kt.injectStyleOnce(lo,mo);const{value:a,onChange:s,onChangeDataUrl:g,label:x,width:$="100%",height:P=200,penColor:M="",penWidth:W=2,minWidth:J=.5,maxWidth:B=4,backgroundColor:I="",placeholder:q,showClearButton:se=!0,showUndoButton:oe=!0,showColorPicker:ce=!1,showSizeSlider:Z=!1,velocityFilterWeight:F=.7,throttle:k=16,disabled:l=!1,readOnly:T=!1,displayMode:Y=!1,onBegin:A,onEnd:_,className:b,"data-testid":C}=i,{t:f}=r.useNiceTranslation(),S=q||f("signature.placeholder","Sign here"),K=T||Y,w=Y?!1:se,d=Y?!1:oe,D=Y?!1:ce,j=Y?!1:Z,h=n.useRef(null),[c,p]=n.useState(a?.strokes??[]),[E,N]=n.useState([]),[m,R]=n.useState(!1),[z,ie]=n.useState(M),[v,ee]=n.useState(W),U=n.useRef(null),me=n.useRef(0),pe=r.useThemeIsDark(h),ye=I||(pe?"#0f172a":"#ffffff"),ue=M||(pe?"#f8fafc":"#111827"),he=z||ue,de=c.length===0&&E.length===0;n.useEffect(()=>{const O=h.current;if(!O)return;const y=O.getContext("2d");if(!y)return;const G=O.getBoundingClientRect(),ne=window.devicePixelRatio||1;O.width=G.width*ne,O.height=G.height*ne,y.scale(ne,ne),ge()},[$,P]);const ge=n.useCallback(()=>{const O=h.current;if(!O)return;const y=O.getContext("2d");if(!y)return;const G=O.getBoundingClientRect();y.fillStyle=ye,y.fillRect(0,0,G.width,G.height),c.forEach(ne=>{if(y.strokeStyle=ne.color||ue,!(ne.points.length<2))for(let le=1;le<ne.points.length;le++){const be=ne.points[le-1],xe=ne.points[le],Se=nn(xe,be,J,B);on(y,be,xe,Se)}})},[c,ye,ue,J,B,F]);n.useEffect(()=>{ge()},[ge]),n.useEffect(()=>{a?.strokes&&p(a.strokes)},[a]),n.useEffect(()=>{const O=h.current;if(O)if(c.length===0)s?.(null),g?.(null);else{const y=O.getBoundingClientRect();s?.({strokes:c,width:y.width,height:y.height,timestamp:Date.now()}),g?.(O.toDataURL("image/png"))}},[c,s,g]);const ae=n.useCallback(O=>{if(l||K)return;const y=h.current;if(!y)return;y.setPointerCapture(O.pointerId);const G=tn(O.nativeEvent,y);R(!0),N([G]),U.current=G,me.current=G.time,A?.()},[l,K,A]),ve=n.useCallback(O=>{if(!m||l||K)return;const y=h.current;if(!y)return;const G=y.getContext("2d");if(!G)return;const ne=Date.now();if(ne-me.current<k)return;const le=tn(O.nativeEvent,y),be=U.current;if(be){G.strokeStyle=he;const xe=nn(le,be,J,B);on(G,be,le,xe)}N(xe=>[...xe,le]),U.current=le,me.current=ne},[m,l,K,he,J,B,F,k]),_e=n.useCallback(O=>{if(!m)return;const y=h.current;if(y&&y.releasePointerCapture(O.pointerId),E.length>0){const G={points:E,color:he,width:v};p(ne=>[...ne,G])}R(!1),N([]),U.current=null,_?.()},[m,E,he,v,_]),te=n.useCallback(()=>{p([]),N([]),ge()},[ge]),we=n.useCallback(()=>{p(O=>O.slice(0,-1))},[]),re=n.useCallback((O="png",y=.92)=>{const G=h.current;if(!G)return"";const ne=O==="jpeg"?"image/jpeg":"image/png";return G.toDataURL(ne,y)},[]),fe=n.useCallback(async(O="png",y=.92)=>{const G=h.current;return G?new Promise(ne=>{const le=O==="jpeg"?"image/jpeg":"image/png";G.toBlob(be=>ne(be),le,y)}):null},[]),H=n.useCallback(()=>{const O=h.current;if(!O)return"";const y=O.getBoundingClientRect(),G=c.map(ne=>ne.points.length<2?"":`<path d="${ne.points.reduce((be,xe,Se)=>Se===0?`M ${xe.x} ${xe.y}`:`${be} L ${xe.x} ${xe.y}`,"")}" stroke="${ne.color||ue}" stroke-width="${ne.width}" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`).join(`
|
|
307
307
|
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${y.width}" height="${y.height}" viewBox="0 0 ${O.width} ${O.height}">
|
|
308
308
|
<rect width="100%" height="100%" fill="${ye}"/>
|
|
309
309
|
${G}
|
|
310
|
-
</svg>`},[c,ye,ue]);n.useImperativeHandle(o,()=>({clear:te,undo:we,isEmpty:()=>c.length===0,getData:()=>{const O=h.current;if(!O||c.length===0)return null;const y=O.getBoundingClientRect();return{strokes:c,width:y.width,height:y.height,timestamp:Date.now()}},setData:O=>{p(O.strokes)},toDataURL:re,toBlob:fe,toSVG:H,getCanvas:()=>h.current}),[c,te,we,re,fe,H]),n.useEffect(()=>{const O=h.current;if(!O)return;const y=G=>{m&&G.preventDefault()};return O.addEventListener("touchmove",y,{passive:!1}),()=>O.removeEventListener("touchmove",y)},[m]);const
|
|
310
|
+
</svg>`},[c,ye,ue]);n.useImperativeHandle(o,()=>({clear:te,undo:we,isEmpty:()=>c.length===0,getData:()=>{const O=h.current;if(!O||c.length===0)return null;const y=O.getBoundingClientRect();return{strokes:c,width:y.width,height:y.height,timestamp:Date.now()}},setData:O=>{p(O.strokes)},toDataURL:re,toBlob:fe,toSVG:H,getCanvas:()=>h.current}),[c,te,we,re,fe,H]),n.useEffect(()=>{const O=h.current;if(!O)return;const y=G=>{m&&G.preventDefault()};return O.addEventListener("touchmove",y,{passive:!1}),()=>O.removeEventListener("touchmove",y)},[m]);const X=w||d||D||j;return e.jsxs("div",{className:`nice-signature ${l?"nice-signature--disabled":""} ${K?"nice-signature--readonly":""} ${b??""}`,style:{width:$},"data-testid":C,children:[x&&e.jsx("label",{className:"nice-signature__label",children:x}),X&&e.jsxs("div",{className:"nice-signature__toolbar",children:[D&&e.jsx("div",{className:"nice-signature__color-picker",children:e.jsx("input",{type:"color",value:z,onChange:O=>ie(O.target.value),disabled:l||K,title:f("signature.penColor","Pen color")})}),j&&e.jsx("div",{className:"nice-signature__size-slider",children:e.jsx("input",{type:"range",min:J,max:B,step:.5,value:v,onChange:O=>ee(parseFloat(O.target.value)),disabled:l||K,title:f("signature.penSize","Pen size")})}),e.jsxs("div",{className:"nice-signature__actions",children:[d&&e.jsx("button",{type:"button",onClick:we,disabled:l||K||c.length===0,className:"nice-signature__btn",title:f("signature.undo","Undo"),"aria-label":f("signature.undo","Undo"),children:e.jsx(r.NiceIcon,{name:"reply",size:16})}),w&&e.jsx("button",{type:"button",onClick:te,disabled:l||K||de,className:"nice-signature__btn",title:f("signature.clear","Clear"),"aria-label":f("signature.clear","Clear"),children:e.jsx(r.NiceIcon,{name:"trash",size:16})})]})]}),e.jsxs("div",{className:"nice-signature__canvas-wrapper",style:{height:P},children:[e.jsx("canvas",{ref:h,className:"nice-signature__canvas",style:{width:"100%",height:"100%",cursor:l||K?"not-allowed":"crosshair",touchAction:"none"},onPointerDown:ae,onPointerMove:ve,onPointerUp:_e,onPointerLeave:_e}),de&&!m&&S&&e.jsx("div",{className:"nice-signature__placeholder",children:S}),e.jsx("div",{className:"nice-signature__line"})]})]})}),lo="nice-signature-styles",mo=`
|
|
311
311
|
.nice-signature {
|
|
312
312
|
display: flex;
|
|
313
313
|
flex-direction: column;
|
|
@@ -428,5 +428,5 @@ ${D.join(`
|
|
|
428
428
|
color: var(--nice-text-secondary, #999);
|
|
429
429
|
font-size: 14px;
|
|
430
430
|
}
|
|
431
|
-
`,po=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",id:$,className:P,style:M,accessMode:W,mode:J="manual",onScan:B,onModeChange:I,beepOnScan:X=!0,beepFrequency:se=1800,beepDuration:oe=150,placeholder:ce,scanHistory:Z=[],showHistory:F=!0,maxHistory:k=10,autoFocus:l=!0,onCameraFrame:T},Y)=>{const A=r.useNiceAccessMode(W,$),_=A==="hidden";A==="disabled"&&(s=!0),A==="readOnly"&&(g=!0);const{t:b}=r.useNiceTranslation(),C=r.useControlId($),[f,S]=n.useState(""),K=n.useRef(null),w=n.useRef(null),d=n.useCallback(()=>{if(X)try{w.current||(w.current=new AudioContext);const h=w.current,c=h.createOscillator(),p=h.createGain();c.connect(p),p.connect(h.destination),c.frequency.value=se,c.type="square",p.gain.value=.3,c.start(),c.stop(h.currentTime+oe/1e3)}catch{}},[X,se,oe]),D=n.useCallback(()=>{f.trim()&&(d(),B?.({value:f.trim(),format:"manual",scannedAt:new Date}),S(""),K.current?.focus())},[f,B,d]),j=Z.slice(0,k);return _?null:e.jsxs("div",{ref:Y,id:C,className:`nice-scanner nice-size-${x}${P?` ${P}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:M,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,a&&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${J==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>I?.("camera"),disabled:s,children:[e.jsx(r.NiceIcon,{name:"camera",size:16})," ",b("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${J==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>I?.("manual"),disabled:s,children:[e.jsx(r.NiceIcon,{name:"edit",size:16})," ",b("manual","Manual")]})]}),J==="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(r.NiceIcon,{name:"camera",size:32})}),e.jsx("p",{children:b("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),J==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:K,className:"nice-input nice-scanner__input",type:"text",value:f,onChange:h=>S(h.target.value),onKeyDown:h=>h.key==="Enter"&&D(),placeholder:ce??b("enterCode","Enter or scan code…"),disabled:s,autoFocus:l}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:D,disabled:s||!f.trim(),"aria-label":b("submit","Submit"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),F&&j.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:b("recentScans","Recent scans")}),j.map((h,c)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:h.value}),h.format&&e.jsx("span",{className:"nice-scanner__history-format",children:h.format}),e.jsx("span",{className:"nice-scanner__history-time",children:h.scannedAt.toLocaleTimeString()})]},c))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceScannerControl"}),ho=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let go=1;function fo(t){return{id:`new-${go++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"pcs"}}function $n(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),a=Math.round(o*100)/100,s=Math.round(a*(t.vatRate??0)/100*100)/100;return{...t,netAmount:a,grossAmount:a+s}}function yo(t){const i=t.map($n),o=i.reduce(($,P)=>$+(P.netAmount??0),0),a=i.reduce(($,P)=>$+(P.grossAmount??0),0),s=a-o,g=new Map;for(const $ of i){const P=$.vatRate??0,M=g.get(P)??{base:0,amount:0};M.base+=$.netAmount??0,M.amount+=($.grossAmount??0)-($.netAmount??0),g.set(P,M)}const x=Array.from(g.entries()).map(([$,P])=>({rate:$,base:Math.round(P.base*100)/100,amount:Math.round(P.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(s*100)/100,totalGross:Math.round(a*100)/100,vatBreakdown:x}}const xo={pl:"PLN",cs:"CZK",sk:"EUR",hu:"HUF",ro:"RON",bg:"BGN",uk:"UAH",de:"EUR",fr:"EUR",es:"EUR",it:"EUR",nl:"EUR",pt:"EUR",fi:"EUR",sv:"SEK",no:"NOK",da:"DKK",ja:"JPY",zh:"CNY",ko:"KRW",hi:"INR",th:"THB",vi:"VND",id:"IDR",ms:"MYR",fil:"PHP",bn:"BDT",ar:"AED",sw:"KES"};function bo(t){const i=xo[t];if(!i)return"$";try{return new Intl.NumberFormat(t,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(0).find(a=>a.type==="currency")?.value??"$"}catch{return"$"}}const jo=["pcs","h","kg","m","svc"],vo=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B=[],onChange:I,onTotalsChange:X,currencySymbol:se,defaultVatRate:oe=23,vatRates:ce=[0,5,8,23],units:Z,showDiscount:F=!0,showUnit:k=!0,showTotals:l=!0,editable:T=!0,maxLines:Y,tutorial:A},_)=>{const b=r.useNiceAccessMode(J,P),C=b==="hidden";b==="disabled"&&(s=!0),b==="readOnly"&&(g=!0);const{t:f,lang:S}=r.useNiceTranslation(),K=r.useControlId(P),w=n.useMemo(()=>se??bo(S),[se,S]),d=n.useMemo(()=>Z??jo.map(N=>f(`invoice.unit.${N}`,N)),[Z,f]),D=n.useMemo(()=>B.map($n),[B]),j=n.useMemo(()=>yo(B),[B]);n.useEffect(()=>{X?.(j)},[j,X]);const h=n.useCallback((N,m,R)=>{const z=[...B];z[N]={...z[N],[m]:R},I?.(z)},[B,I]),c=n.useCallback(()=>{Y&&B.length>=Y||I?.([...B,fo(oe)])},[B,I,oe,Y]),p=n.useCallback(N=>{I?.(B.filter((m,R)=>R!==N))},[B,I]),E=N=>`${N.toFixed(2)} ${w}`;return C?null:e.jsxs("div",{ref:_,id:K,className:`nice-invoice-lines nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:{position:"relative",...W},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(A,ho)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,a&&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:f("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:f("qty","Qty")}),k&&e.jsx("th",{className:"nice-il__th-unit",children:f("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:f("unitPrice","Unit Price")}),F&&e.jsx("th",{className:"nice-il__th-disc",children:f("invoice.discountPct","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:f("invoice.vatPct","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:f("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:f("gross","Gross")}),T&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:D.map((N,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:N.description,onChange:R=>h(m,"description",R.target.value),disabled:s,readOnly:g,placeholder:f("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:N.quantity,onChange:R=>h(m,"quantity",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,step:"any"})}),k&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:N.unit??"",onChange:R=>h(m,"unit",R.target.value),disabled:s,children:d.map(R=>e.jsx("option",{value:R,children:R},R))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:N.unitPrice,onChange:R=>h(m,"unitPrice",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,step:"0.01"})}),F&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:N.discount??0,onChange:R=>h(m,"discount",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:N.vatRate??0,onChange:R=>h(m,"vatRate",parseInt(R.target.value,10)),disabled:s,children:ce.map(R=>e.jsxs("option",{value:R,children:[R,"%"]},R))})}),e.jsx("td",{className:"nice-il__cell-net",children:E(N.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:E(N.grossAmount??0)}),T&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>p(m),disabled:s,title:f("remove","Remove"),"aria-label":f("remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})})]},N.id))})]}),T&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:c,disabled:s||Y!=null&&B.length>=Y,children:["+ ",f("addLine","Add line")]}),l&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[f("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:E(j.totalNet)})]}),j.vatBreakdown.map(N=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsx("span",{children:f("invoice.vat","VAT {rate}%:").replace("{rate}",String(N.rate))}),e.jsx("span",{className:"nice-il__total-value",children:E(N.amount)})]},N.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[f("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:E(j.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceInvoiceLineEditor"}),_o=Object.assign(n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:a,trigger:s="@",renderSuggestion:g,placeholder:x,rows:$=3,label:P,helperText:M,error:W,required:J,disabled:B,readOnly:I,loading:X,labelPlacement:se,errorPlacement:oe,labelWidth:ce,controlWidth:Z,size:F="md",name:k,id:l,className:T,style:Y,...A},_)=>{const b=r.useControlId(l),[C,f]=n.useState(!1),[S,K]=n.useState(""),[w,d]=n.useState(0),[D,j]=n.useState({top:0,left:0}),h=n.useRef(null),c=n.useRef(-1),E=o.map(U=>typeof U=="string"?{key:U,label:U}:U).filter(U=>U.label.toLowerCase().includes(S.toLowerCase())),N=n.useCallback(()=>{f(!1),K(""),d(0),c.current=-1},[]),m=n.useCallback(U=>{const me=h.current;if(!me||c.current<0)return;const pe=t.slice(0,c.current),ye=t.slice(me.selectionStart),ue=`${s}${U.label} `,he=pe+ue+ye;i?.(he),N(),requestAnimationFrame(()=>{const de=pe.length+ue.length;me.setSelectionRange(de,de),me.focus()})},[t,i,s,N]),R=n.useCallback(U=>{const me=U.target.value;i?.(me);const pe=U.target.selectionStart,ye=me.slice(0,pe),ue=ye.lastIndexOf(s);if(ue>=0){const he=ue>0?ye[ue-1]:" ",de=ye.slice(ue+s.length);if(/\s/.test(he)&&!/\s/.test(de)){c.current=ue;const ge=de;K(ge),f(!0),d(0),a?.(ge);const ae=U.target,ve=ae.getBoundingClientRect(),_e=parseInt(getComputedStyle(ae).lineHeight)||20,te=ye.split(`
|
|
432
|
-
`);j({top:ve.top+te.length*_e+4-ae.scrollTop,left:ve.left+8});return}}N()},[i,s,a,N]),z=n.useCallback(U=>{!C||E.length===0||(U.key==="ArrowDown"?(U.preventDefault(),d(me=>(me+1)%E.length)):U.key==="ArrowUp"?(U.preventDefault(),d(me=>(me-1+E.length)%E.length)):U.key==="Enter"?(U.preventDefault(),E[w]&&m(E[w])):U.key==="Escape"&&N())},[C,E,w,m,N]),ie=C&&E.length>0,v=n.useRef(null),ee=`${b}-suggestions`;return r.useIntent(["navigate","activate"],U=>{if(U.source==="keyboard")return!1;if(U.intent==="activate"){const pe=E[w];if(!pe)return!1;m(pe);return}if(U.direction!=="up"&&U.direction!=="down")return!1;const me=U.direction==="down"?1:-1;d(pe=>(pe+me+E.length)%E.length)},{ref:v,enabled:ie}),n.useEffect(()=>{if(!C)return;const U=me=>{const pe=h.current;pe&&!pe.contains(me.target)&&N()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[C,N]),e.jsxs("div",{className:`nice-field nice-field--${F} ${se==="left"?"nice-field--label-left":""} ${oe==="right"?"nice-field--error-right":""} ${
|
|
431
|
+
`,uo=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",id:$,className:P,style:M,accessMode:W,mode:J="manual",onScan:B,onModeChange:I,beepOnScan:q=!0,beepFrequency:se=1800,beepDuration:oe=150,placeholder:ce,scanHistory:Z=[],showHistory:F=!0,maxHistory:k=10,autoFocus:l=!0,onCameraFrame:T},Y)=>{const A=r.useNiceAccessMode(W,$),_=A==="hidden";A==="disabled"&&(s=!0),A==="readOnly"&&(g=!0);const{t:b}=r.useNiceTranslation(),C=r.useControlId($),[f,S]=n.useState(""),K=n.useRef(null),w=n.useRef(null),d=n.useCallback(()=>{if(q)try{w.current||(w.current=new AudioContext);const h=w.current,c=h.createOscillator(),p=h.createGain();c.connect(p),p.connect(h.destination),c.frequency.value=se,c.type="square",p.gain.value=.3,c.start(),c.stop(h.currentTime+oe/1e3)}catch{}},[q,se,oe]),D=n.useCallback(()=>{f.trim()&&(d(),B?.({value:f.trim(),format:"manual",scannedAt:new Date}),S(""),K.current?.focus())},[f,B,d]),j=Z.slice(0,k);return _?null:e.jsxs("div",{ref:Y,id:C,className:`nice-scanner nice-size-${x}${P?` ${P}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:M,children:[t&&e.jsxs("div",{className:"nice-scanner__label",children:[t,a&&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${J==="camera"?" nice-scanner__mode-btn--active":""}`,onClick:()=>I?.("camera"),disabled:s,children:[e.jsx(r.NiceIcon,{name:"camera",size:16})," ",b("camera","Camera")]}),e.jsxs("button",{type:"button",className:`nice-scanner__mode-btn${J==="manual"?" nice-scanner__mode-btn--active":""}`,onClick:()=>I?.("manual"),disabled:s,children:[e.jsx(r.NiceIcon,{name:"edit",size:16})," ",b("manual","Manual")]})]}),J==="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(r.NiceIcon,{name:"camera",size:32})}),e.jsx("p",{children:b("cameraPlaceholder","Camera preview — connect scanner adapter")})]})})}),J==="manual"&&!g&&e.jsxs("div",{className:"nice-scanner__manual",children:[e.jsx("input",{ref:K,className:"nice-input nice-scanner__input",type:"text",value:f,onChange:h=>S(h.target.value),onKeyDown:h=>h.key==="Enter"&&D(),placeholder:ce??b("enterCode","Enter or scan code…"),disabled:s,autoFocus:l}),e.jsx("button",{type:"button",className:"nice-scanner__submit",onClick:D,disabled:s||!f.trim(),"aria-label":b("submit","Submit"),children:e.jsx(r.NiceIcon,{name:"check",size:16})})]}),F&&j.length>0&&e.jsxs("div",{className:"nice-scanner__history",children:[e.jsx("div",{className:"nice-scanner__history-label",children:b("recentScans","Recent scans")}),j.map((h,c)=>e.jsxs("div",{className:"nice-scanner__history-item",children:[e.jsx("span",{className:"nice-scanner__history-value",children:h.value}),h.format&&e.jsx("span",{className:"nice-scanner__history-format",children:h.format}),e.jsx("span",{className:"nice-scanner__history-time",children:h.scannedAt.toLocaleTimeString()})]},c))]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceScannerControl"}),po=[{target:".nice-invoice-lines",titleKey:"tutorial.invoiceLineEditor.intro.title",title:"Invoice lines",contentKey:"tutorial.invoiceLineEditor.intro.content",content:"Add line items with quantity, unit price, VAT and discount — net, gross and the VAT breakdown are calculated automatically.",placement:"auto"}];let ho=1;function go(t){return{id:`new-${ho++}`,description:"",quantity:1,unitPrice:0,vatRate:t,discount:0,unit:"pcs"}}function En(t){const o=t.quantity*t.unitPrice*(1-(t.discount??0)/100),a=Math.round(o*100)/100,s=Math.round(a*(t.vatRate??0)/100*100)/100;return{...t,netAmount:a,grossAmount:a+s}}function fo(t){const i=t.map(En),o=i.reduce(($,P)=>$+(P.netAmount??0),0),a=i.reduce(($,P)=>$+(P.grossAmount??0),0),s=a-o,g=new Map;for(const $ of i){const P=$.vatRate??0,M=g.get(P)??{base:0,amount:0};M.base+=$.netAmount??0,M.amount+=($.grossAmount??0)-($.netAmount??0),g.set(P,M)}const x=Array.from(g.entries()).map(([$,P])=>({rate:$,base:Math.round(P.base*100)/100,amount:Math.round(P.amount*100)/100}));return{totalNet:Math.round(o*100)/100,totalVat:Math.round(s*100)/100,totalGross:Math.round(a*100)/100,vatBreakdown:x}}const yo={pl:"PLN",cs:"CZK",sk:"EUR",hu:"HUF",ro:"RON",bg:"BGN",uk:"UAH",de:"EUR",fr:"EUR",es:"EUR",it:"EUR",nl:"EUR",pt:"EUR",fi:"EUR",sv:"SEK",no:"NOK",da:"DKK",ja:"JPY",zh:"CNY",ko:"KRW",hi:"INR",th:"THB",vi:"VND",id:"IDR",ms:"MYR",fil:"PHP",bn:"BDT",ar:"AED",sw:"KES"};function xo(t){const i=yo[t];if(!i)return"$";try{return new Intl.NumberFormat(t,{style:"currency",currency:i,minimumFractionDigits:0,maximumFractionDigits:0}).formatToParts(0).find(a=>a.type==="currency")?.value??"$"}catch{return"$"}}const bo=["pcs","h","kg","m","svc"],jo=Object.assign(n.forwardRef(({label:t,helperText:i,error:o,required:a,disabled:s,readOnly:g,size:x="md",name:$,id:P,className:M,style:W,accessMode:J,value:B=[],onChange:I,onTotalsChange:q,currencySymbol:se,defaultVatRate:oe=23,vatRates:ce=[0,5,8,23],units:Z,showDiscount:F=!0,showUnit:k=!0,showTotals:l=!0,editable:T=!0,maxLines:Y,tutorial:A},_)=>{const b=r.useNiceAccessMode(J,P),C=b==="hidden";b==="disabled"&&(s=!0),b==="readOnly"&&(g=!0);const{t:f,lang:S}=r.useNiceTranslation(),K=r.useControlId(P),w=n.useMemo(()=>se??xo(S),[se,S]),d=n.useMemo(()=>Z??bo.map(N=>f(`invoice.unit.${N}`,N)),[Z,f]),D=n.useMemo(()=>B.map(En),[B]),j=n.useMemo(()=>fo(B),[B]);n.useEffect(()=>{q?.(j)},[j,q]);const h=n.useCallback((N,m,R)=>{const z=[...B];z[N]={...z[N],[m]:R},I?.(z)},[B,I]),c=n.useCallback(()=>{Y&&B.length>=Y||I?.([...B,go(oe)])},[B,I,oe,Y]),p=n.useCallback(N=>{I?.(B.filter((m,R)=>R!==N))},[B,I]),E=N=>`${N.toFixed(2)} ${w}`;return C?null:e.jsxs("div",{ref:_,id:K,className:`nice-invoice-lines nice-size-${x}${M?` ${M}`:""}${o?" nice-error":""}${s?" nice-disabled":""}`,style:{position:"relative",...W},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(r.NiceTutorialButton,{steps:r.resolveTutorial(A,po)})}),t&&e.jsxs("label",{className:"nice-invoice-lines__label",children:[t,a&&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:f("description","Description")}),e.jsx("th",{className:"nice-il__th-qty",children:f("qty","Qty")}),k&&e.jsx("th",{className:"nice-il__th-unit",children:f("unit","Unit")}),e.jsx("th",{className:"nice-il__th-price",children:f("unitPrice","Unit Price")}),F&&e.jsx("th",{className:"nice-il__th-disc",children:f("invoice.discountPct","Disc %")}),e.jsx("th",{className:"nice-il__th-vat",children:f("invoice.vatPct","VAT %")}),e.jsx("th",{className:"nice-il__th-net",children:f("net","Net")}),e.jsx("th",{className:"nice-il__th-gross",children:f("gross","Gross")}),T&&!g&&e.jsx("th",{className:"nice-il__th-actions"})]})}),e.jsx("tbody",{children:D.map((N,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:N.description,onChange:R=>h(m,"description",R.target.value),disabled:s,readOnly:g,placeholder:f("itemDescription","Item description")})}),e.jsx("td",{className:"nice-il__cell-qty",children:e.jsx("input",{className:"nice-input",type:"number",value:N.quantity,onChange:R=>h(m,"quantity",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,step:"any"})}),k&&e.jsx("td",{className:"nice-il__cell-unit",children:e.jsx("select",{className:"nice-select",value:N.unit??"",onChange:R=>h(m,"unit",R.target.value),disabled:s,children:d.map(R=>e.jsx("option",{value:R,children:R},R))})}),e.jsx("td",{className:"nice-il__cell-price",children:e.jsx("input",{className:"nice-input",type:"number",value:N.unitPrice,onChange:R=>h(m,"unitPrice",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,step:"0.01"})}),F&&e.jsx("td",{className:"nice-il__cell-disc",children:e.jsx("input",{className:"nice-input",type:"number",value:N.discount??0,onChange:R=>h(m,"discount",parseFloat(R.target.value)||0),disabled:s,readOnly:g,min:0,max:100})}),e.jsx("td",{className:"nice-il__cell-vat",children:e.jsx("select",{className:"nice-select",value:N.vatRate??0,onChange:R=>h(m,"vatRate",parseInt(R.target.value,10)),disabled:s,children:ce.map(R=>e.jsxs("option",{value:R,children:[R,"%"]},R))})}),e.jsx("td",{className:"nice-il__cell-net",children:E(N.netAmount??0)}),e.jsx("td",{className:"nice-il__cell-gross",children:E(N.grossAmount??0)}),T&&!g&&e.jsx("td",{className:"nice-il__cell-actions",children:e.jsx("button",{type:"button",className:"nice-btn nice-btn--icon nice-btn--sm",onClick:()=>p(m),disabled:s,title:f("remove","Remove"),"aria-label":f("remove","Remove"),children:e.jsx(r.NiceIcon,{name:"close",size:14})})})]},N.id))})]}),T&&!g&&e.jsxs("button",{type:"button",className:"nice-btn nice-btn--outlined nice-btn--sm nice-invoice-lines__add",onClick:c,disabled:s||Y!=null&&B.length>=Y,children:["+ ",f("addLine","Add line")]}),l&&e.jsxs("div",{className:"nice-invoice-lines__totals",children:[e.jsxs("div",{className:"nice-il__total-row",children:[e.jsxs("span",{children:[f("totalNet","Net total"),":"]}),e.jsx("span",{className:"nice-il__total-value",children:E(j.totalNet)})]}),j.vatBreakdown.map(N=>e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--vat",children:[e.jsx("span",{children:f("invoice.vat","VAT {rate}%:").replace("{rate}",String(N.rate))}),e.jsx("span",{className:"nice-il__total-value",children:E(N.amount)})]},N.rate)),e.jsxs("div",{className:"nice-il__total-row nice-il__total-row--gross",children:[e.jsxs("span",{children:[f("totalGross","Gross total"),":"]}),e.jsx("span",{className:"nice-il__total-value nice-il__total-value--gross",children:E(j.totalGross)})]})]}),i&&e.jsx("span",{className:"nice-helper-text",children:i}),o&&typeof o=="string"&&e.jsx("span",{className:"nice-error-text",children:o})]})}),{displayName:"NiceInvoiceLineEditor"}),vo=Object.assign(n.forwardRef(({value:t="",onChange:i,suggestions:o=[],onSearch:a,trigger:s="@",renderSuggestion:g,placeholder:x,rows:$=3,label:P,helperText:M,error:W,required:J,disabled:B,readOnly:I,loading:q,labelPlacement:se,errorPlacement:oe,labelWidth:ce,controlWidth:Z,size:F="md",name:k,id:l,className:T,style:Y,...A},_)=>{const b=r.useControlId(l),[C,f]=n.useState(!1),[S,K]=n.useState(""),[w,d]=n.useState(0),[D,j]=n.useState({top:0,left:0}),h=n.useRef(null),c=n.useRef(-1),E=o.map(U=>typeof U=="string"?{key:U,label:U}:U).filter(U=>U.label.toLowerCase().includes(S.toLowerCase())),N=n.useCallback(()=>{f(!1),K(""),d(0),c.current=-1},[]),m=n.useCallback(U=>{const me=h.current;if(!me||c.current<0)return;const pe=t.slice(0,c.current),ye=t.slice(me.selectionStart),ue=`${s}${U.label} `,he=pe+ue+ye;i?.(he),N(),requestAnimationFrame(()=>{const de=pe.length+ue.length;me.setSelectionRange(de,de),me.focus()})},[t,i,s,N]),R=n.useCallback(U=>{const me=U.target.value;i?.(me);const pe=U.target.selectionStart,ye=me.slice(0,pe),ue=ye.lastIndexOf(s);if(ue>=0){const he=ue>0?ye[ue-1]:" ",de=ye.slice(ue+s.length);if(/\s/.test(he)&&!/\s/.test(de)){c.current=ue;const ge=de;K(ge),f(!0),d(0),a?.(ge);const ae=U.target,ve=ae.getBoundingClientRect(),_e=parseInt(getComputedStyle(ae).lineHeight)||20,te=ye.split(`
|
|
432
|
+
`);j({top:ve.top+te.length*_e+4-ae.scrollTop,left:ve.left+8});return}}N()},[i,s,a,N]),z=n.useCallback(U=>{!C||E.length===0||(U.key==="ArrowDown"?(U.preventDefault(),d(me=>(me+1)%E.length)):U.key==="ArrowUp"?(U.preventDefault(),d(me=>(me-1+E.length)%E.length)):U.key==="Enter"?(U.preventDefault(),E[w]&&m(E[w])):U.key==="Escape"&&N())},[C,E,w,m,N]),ie=C&&E.length>0,v=n.useRef(null),ee=`${b}-suggestions`;return r.useIntent(["navigate","activate"],U=>{if(U.source==="keyboard")return!1;if(U.intent==="activate"){const pe=E[w];if(!pe)return!1;m(pe);return}if(U.direction!=="up"&&U.direction!=="down")return!1;const me=U.direction==="down"?1:-1;d(pe=>(pe+me+E.length)%E.length)},{ref:v,enabled:ie}),n.useEffect(()=>{if(!C)return;const U=me=>{const pe=h.current;pe&&!pe.contains(me.target)&&N()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[C,N]),e.jsxs("div",{className:`nice-field nice-field--${F} ${se==="left"?"nice-field--label-left":""} ${oe==="right"?"nice-field--error-right":""} ${q?"nice-field--loading":""} ${T||""}`,style:{...Y,...ce!=null&&{"--nice-field-label-width":typeof ce=="number"?`${ce}px`:ce},...Z!=null&&{"--nice-field-control-width":typeof Z=="number"?`${Z}px`:Z}},"aria-busy":q||void 0,...A,children:[P&&e.jsx("label",{htmlFor:b,className:`nice-field__label ${J?"nice-field__label--required":""}`,children:P}),e.jsxs("div",{className:"nice-field__control",children:[e.jsxs("div",{ref:v,className:`nice-mention nice-mention--${F} ${W?"nice-mention--error":""} ${B?"nice-mention--disabled":""}`,children:[e.jsx("textarea",{ref:U=>{h.current=U,typeof _=="function"?_(U):_&&(_.current=U)},id:b,name:k,className:"nice-mention__input",value:t,onChange:R,onKeyDown:z,placeholder:x,rows:$,disabled:B,readOnly:I,"aria-invalid":!!W,"aria-describedby":W?`${b}-error`:M?`${b}-helper`:void 0,"aria-autocomplete":"list","aria-expanded":ie,"aria-controls":ie?ee:void 0,"aria-activedescendant":ie?`${ee}-${w}`:void 0}),ie&&e.jsx("ul",{id:ee,className:"nice-mention__suggestions",role:"listbox",style:{position:"fixed",top:D.top,left:D.left},children:E.map((U,me)=>e.jsx("li",{id:`${ee}-${me}`,role:"option","aria-selected":me===w,className:`nice-mention__suggestion ${me===w?"nice-mention__suggestion--active":""}`,onMouseDown:pe=>{pe.preventDefault(),m(U)},onMouseEnter:()=>d(me),children:g?g(U):e.jsxs(e.Fragment,{children:[U.icon&&e.jsx("span",{className:"nice-mention__suggestion-icon",children:U.icon}),e.jsx("span",{children:U.label})]})},U.key))})]}),q&&e.jsx("span",{className:"nice-field__spinner",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),oe==="right"&&W&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:W}),oe==="right"&&!W&&M&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:M})]}),oe!=="right"&&W&&e.jsx("div",{id:`${b}-error`,className:"nice-field__error",role:"alert",children:W}),oe!=="right"&&!W&&M&&e.jsx("div",{id:`${b}-helper`,className:"nice-field__helper",children:M})]})}),{displayName:"NiceMention"});exports.DEFAULT_ASPECT_RATIOS=Cn;exports.EMOJI_DATA=vt;exports.GRADIENT_PRESETS=bn;exports.NICE_COLOR_PRESET_KEYS=fn;exports.NiceAccountPicker=Ki;exports.NiceAddressInput=Bi;exports.NiceCodeEditorAI=wi;exports.NiceColorPalette=ai;exports.NiceContactPicker=Ui;exports.NiceCropEditor=Sn;exports.NiceDateRangeBox=Vn;exports.NiceDocumentEditor=vi;exports.NiceDropDownBox=Fn;exports.NiceEmojiPicker=Nn;exports.NiceGradientPicker=ci;exports.NiceHtmlEditorAI=mi;exports.NiceImageAnnotator=no;exports.NiceImageEditor=Gi;exports.NiceInputOtp=Xi;exports.NiceInvoiceLineEditor=jo;exports.NiceKeyValueEditor=zi;exports.NiceKnob=Pn;exports.NiceLogConsole=wn;exports.NiceLookup=On;exports.NiceMarkdownEditor=vn;exports.NiceMention=vo;exports.NicePDFAnnotationEditor=ro;exports.NicePickList=Xn;exports.NiceRangeSlider=zn;exports.NiceScannerControl=uo;exports.NiceScriptRunner=Ti;exports.NiceSignature=co;exports.NiceTreeSelect=Hn;exports.NiceWiki=ki;exports.applyPreset=jt;exports.contrastRatio=xt;exports.cssToGradient=xn;exports.generateHarmony=mt;exports.generateVariations=pn;exports.gradientToCss=Mt;exports.hexToHsv=Ye;exports.hexToRgb=ut;exports.hsvToHex=Be;exports.hsvToRgb=dn;exports.randomPalette=gn;exports.rgbToHex=un;exports.rgbToHsl=mn;exports.rgbToHsv=Rt;exports.wcagLevel=bt;
|