@nice2dev/ui-enterprise 1.0.10

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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @nice2dev/ui-enterprise
2
+
3
+ Compliance & enterprise-grade React components for Nice2Dev. Moved from `@nice2dev/ui` in v1.0.10.
4
+
5
+ ## Components (7)
6
+
7
+ - `NiceDataExportCenter`, `NiceAuditTrail`, `NiceContractEditor`, `NiceGDPRConsent`,
8
+ `NiceGlobalSearch`, `NiceInvoiceDesigner`, `NiceAccessLog`
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm install @nice2dev/ui-enterprise
14
+ ```
15
+
16
+ ## License
17
+
18
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react");function Re(s,a,n){const c=n.csvDelimiter||",",l=[];return n.includeHeaders!==!1&&l.push(a.filter(r=>r.include).map(r=>`"${r.label}"`).join(c)),s.forEach(r=>{const u=a.filter(o=>o.include).map(o=>{let p=r[o.field];return o.transform&&(p=o.transform(p)),p==null?"":typeof p=="string"?`"${p.replace(/"/g,'""')}"`:String(p)});l.push(u.join(c))}),l.join(`
2
+ `)}function Pe(s,a,n){const c=a.filter(r=>r.include),l=s.map(r=>{const u={};return c.forEach(o=>{let p=r[o.field];o.transform&&(p=o.transform(p)),u[o.field]=p}),u});return JSON.stringify(l,null,2)}const pe={csv:{label:"CSV",icon:"πŸ“„",description:"Comma-separated values"},xlsx:{label:"Excel",icon:"πŸ“Š",description:"Microsoft Excel"},json:{label:"JSON",icon:"{ }",description:"JavaScript Object Notation"},pdf:{label:"PDF",icon:"πŸ“•",description:"Portable Document Format"},xml:{label:"XML",icon:"πŸ“‹",description:"Extensible Markup Language"}},Me=({formats:s,selected:a,onChange:n})=>e.jsx("div",{className:"nice-export-formats",children:s.map(c=>{const l=pe[c];return e.jsxs("button",{type:"button",className:`nice-export-format ${a===c?"nice-export-format--selected":""}`,onClick:()=>n(c),title:l.description,children:[e.jsx("span",{className:"nice-export-format-icon",children:l.icon}),e.jsx("span",{className:"nice-export-format-label",children:l.label})]},c)})}),Oe=({fields:s,onChange:a})=>{const n=r=>{const u=[...s];u[r]={...u[r],include:!u[r].include},a(u)},c=r=>{a(s.map(u=>({...u,include:r})))},l=s.filter(r=>r.include).length;return e.jsxs("div",{className:"nice-export-fields",children:[e.jsxs("div",{className:"nice-export-fields-header",children:[e.jsxs("span",{children:["Fields to export (",l,"/",s.length,")"]}),e.jsxs("div",{className:"nice-export-fields-actions",children:[e.jsx("button",{type:"button",onClick:()=>c(!0),children:"Select all"}),e.jsx("button",{type:"button",onClick:()=>c(!1),children:"Deselect all"})]})]}),e.jsx("div",{className:"nice-export-fields-list",children:s.map((r,u)=>e.jsxs("label",{className:"nice-export-field",children:[e.jsx("input",{type:"checkbox",checked:r.include,onChange:()=>n(u)}),e.jsx("span",{className:"nice-export-field-label",children:r.label}),e.jsx("span",{className:"nice-export-field-name",children:r.field})]},r.field))})]})},Ue=({format:s,options:a,onChange:n})=>{const c=(l,r)=>{n({...a,[l]:r})};return e.jsxs("div",{className:"nice-export-options",children:[e.jsx("h4",{children:"Export Options"}),e.jsxs("label",{className:"nice-export-option",children:[e.jsx("input",{type:"checkbox",checked:a.includeHeaders!==!1,onChange:l=>c("includeHeaders",l.target.checked)}),"Include headers"]}),s==="csv"&&e.jsxs("label",{className:"nice-export-option",children:[e.jsx("span",{children:"Delimiter:"}),e.jsxs("select",{value:a.csvDelimiter||",",onChange:l=>c("csvDelimiter",l.target.value),children:[e.jsx("option",{value:",",children:"Comma (,)"}),e.jsx("option",{value:";",children:"Semicolon (;)"}),e.jsx("option",{value:"\\t",children:"Tab"}),e.jsx("option",{value:"|",children:"Pipe (|)"})]})]}),e.jsxs("label",{className:"nice-export-option",children:[e.jsx("span",{children:"Date format:"}),e.jsxs("select",{value:a.dateFormat||"YYYY-MM-DD",onChange:l=>c("dateFormat",l.target.value),children:[e.jsx("option",{value:"YYYY-MM-DD",children:"YYYY-MM-DD"}),e.jsx("option",{value:"DD/MM/YYYY",children:"DD/MM/YYYY"}),e.jsx("option",{value:"MM/DD/YYYY",children:"MM/DD/YYYY"}),e.jsx("option",{value:"ISO",children:"ISO 8601"})]})]}),e.jsxs("label",{className:"nice-export-option",children:[e.jsx("span",{children:"Encoding:"}),e.jsxs("select",{value:a.encoding||"utf-8",onChange:l=>c("encoding",l.target.value),children:[e.jsx("option",{value:"utf-8",children:"UTF-8"}),e.jsx("option",{value:"utf-16",children:"UTF-16"}),e.jsx("option",{value:"iso-8859-1",children:"ISO-8859-1"})]})]}),(s==="xlsx"||s==="pdf")&&e.jsxs("label",{className:"nice-export-option",children:[e.jsx("span",{children:"Password protect:"}),e.jsx("input",{type:"password",value:a.password||"",onChange:l=>c("password",l.target.value||void 0),placeholder:"Leave empty for no password"})]})]})},Ye=({jobs:s,onDownload:a})=>{if(s.length===0)return e.jsx("div",{className:"nice-export-history-empty",children:"No export history"});const n=c=>c?c<1024?`${c} B`:c<1024*1024?`${(c/1024).toFixed(1)} KB`:`${(c/1024/1024).toFixed(1)} MB`:"-";return e.jsxs("div",{className:"nice-export-history",children:[e.jsx("h4",{children:"Export History"}),e.jsx("div",{className:"nice-export-history-list",children:s.map(c=>e.jsxs("div",{className:`nice-export-job nice-export-job--${c.status}`,children:[e.jsxs("div",{className:"nice-export-job-info",children:[e.jsx("span",{className:"nice-export-job-name",children:c.name}),e.jsx("span",{className:"nice-export-job-format",children:c.format.toUpperCase()}),e.jsx("span",{className:"nice-export-job-date",children:new Date(c.createdAt).toLocaleString()})]}),e.jsxs("div",{className:"nice-export-job-meta",children:[c.rowCount&&e.jsxs("span",{children:[c.rowCount," rows"]}),c.fileSize&&e.jsx("span",{children:n(c.fileSize)})]}),e.jsxs("div",{className:"nice-export-job-status",children:[c.status==="processing"&&e.jsx("div",{className:"nice-export-job-progress",children:e.jsx("div",{className:"nice-export-job-progress-bar",style:{width:`${c.progress}%`}})}),c.status==="completed"&&c.downloadUrl&&e.jsx("button",{type:"button",className:"nice-export-job-download",onClick:()=>a==null?void 0:a(c),children:"Download"}),c.status==="failed"&&e.jsx("span",{className:"nice-export-job-error",title:c.error,children:"Failed"})]})]},c.id))})]})},we=i.forwardRef(({dataSource:s,formats:a=["csv","xlsx","json","pdf"],templates:n=[],enableScheduling:c=!1,exportHistory:l=[],onExportStart:r,onExportComplete:u,onExportError:o,onSaveTemplate:p,onDeleteTemplate:F,onSchedule:z,customExportHandler:g,title:S="Data Export",description:M,className:L="",style:W},U)=>{const[G,Y]=i.useState(a[0]),[q,x]=i.useState(s.getFields()),[D,v]=i.useState({includeHeaders:!0,dateFormat:"YYYY-MM-DD",encoding:"utf-8"}),[f,O]=i.useState(!1),[b,R]=i.useState(0),[_,E]=i.useState("export"),P=i.useCallback(async()=>{const j={id:Date.now().toString(),name:`Export ${new Date().toISOString()}`,format:G,status:"processing",progress:0,createdAt:new Date};O(!0),R(0),r==null||r(j);try{const $=await s.fetchData({fields:q,filters:void 0,sorting:void 0});R(50);let T;if(g)T=await g(G,$,D);else switch(G){case"csv":T=Re($,q,D);break;case"json":T=Pe($,q,D);break;default:throw new Error(`Format ${G} requires a custom export handler`)}R(100);const K=typeof T=="string"?new Blob([T],{type:"text/plain"}):T,A=URL.createObjectURL(K),N=document.createElement("a");N.href=A,N.download=`export-${Date.now()}.${G}`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(A);const m={...j,status:"completed",progress:100,completedAt:new Date,rowCount:$.length,fileSize:K.size};u==null||u(m)}catch($){const T={...j,status:"failed",error:$ instanceof Error?$.message:"Unknown error"};o==null||o(T,$ instanceof Error?$:new Error("Export failed"))}finally{O(!1),R(0)}},[G,q,D,s,g,r,u,o]),J=i.useCallback(j=>{const $=n.find(T=>T.id===j);$&&(Y($.format),x($.fields),$.options&&v($.options))},[n]);return i.useImperativeHandle(U,()=>({exportNow:async j=>{Y(j),await P()},getSelectedFields:()=>q,loadTemplate:J})),e.jsxs("div",{className:`nice-export-center ${L}`,style:W,children:[e.jsx("div",{className:"nice-export-header",children:e.jsxs("div",{className:"nice-export-title-area",children:[e.jsx("h3",{className:"nice-export-title",children:S}),M&&e.jsx("p",{className:"nice-export-description",children:M})]})}),e.jsxs("div",{className:"nice-export-tabs",children:[e.jsx("button",{type:"button",className:`nice-export-tab ${_==="export"?"nice-export-tab--active":""}`,onClick:()=>E("export"),children:"Export"}),n.length>0&&e.jsxs("button",{type:"button",className:`nice-export-tab ${_==="templates"?"nice-export-tab--active":""}`,onClick:()=>E("templates"),children:["Templates (",n.length,")"]}),l.length>0&&e.jsx("button",{type:"button",className:`nice-export-tab ${_==="history"?"nice-export-tab--active":""}`,onClick:()=>E("history"),children:"History"})]}),e.jsxs("div",{className:"nice-export-content",children:[_==="export"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{formats:a,selected:G,onChange:Y}),e.jsx(Oe,{fields:q,onChange:x}),e.jsx(Ue,{format:G,options:D,onChange:v}),e.jsxs("div",{className:"nice-export-actions",children:[e.jsx("button",{type:"button",className:"nice-export-btn nice-export-btn--primary",onClick:P,disabled:f||q.filter(j=>j.include).length===0,children:f?`Exporting... ${b}%`:"Export Now"}),p&&e.jsx("button",{type:"button",className:"nice-export-btn nice-export-btn--secondary",onClick:()=>p({id:Date.now().toString(),name:`Template ${n.length+1}`,format:G,fields:q,options:D}),children:"Save as Template"})]})]}),_==="templates"&&e.jsx("div",{className:"nice-export-templates",children:n.map(j=>e.jsxs("div",{className:"nice-export-template",children:[e.jsxs("div",{className:"nice-export-template-info",children:[e.jsx("span",{className:"nice-export-template-name",children:j.name}),e.jsxs("span",{className:"nice-export-template-format",children:[pe[j.format].icon," ",pe[j.format].label]}),j.description&&e.jsx("span",{className:"nice-export-template-desc",children:j.description})]}),e.jsxs("div",{className:"nice-export-template-actions",children:[e.jsx("button",{type:"button",onClick:()=>{J(j.id),E("export")},children:"Use"}),F&&e.jsx("button",{type:"button",onClick:()=>F(j.id),children:"Delete"})]})]},j.id))}),_==="history"&&e.jsx(Ye,{jobs:l,onDownload:j=>{j.downloadUrl&&window.open(j.downloadUrl,"_blank")}})]})]})});we.displayName="NiceDataExportCenter";const le={create:{icon:"+",label:"Created",color:"var(--color-success, #10b981)"},update:{icon:"✎",label:"Updated",color:"var(--color-primary, #3b82f6)"},delete:{icon:"Γ—",label:"Deleted",color:"var(--color-error, #ef4444)"},view:{icon:"πŸ‘",label:"Viewed",color:"var(--text-muted, #6b7280)"},export:{icon:"↓",label:"Exported",color:"var(--color-accent, #8b5cf6)"},import:{icon:"↑",label:"Imported",color:"var(--color-accent, #8b5cf6)"},approve:{icon:"βœ“",label:"Approved",color:"var(--color-success, #10b981)"},reject:{icon:"βœ—",label:"Rejected",color:"var(--color-error, #ef4444)"},login:{icon:"β†’",label:"Login",color:"var(--color-success, #10b981)"},logout:{icon:"←",label:"Logout",color:"var(--text-muted, #6b7280)"},permission_change:{icon:"πŸ”",label:"Permissions",color:"var(--color-warning, #f59e0b)"},config_change:{icon:"βš™",label:"Config",color:"var(--color-warning, #f59e0b)"},custom:{icon:"β€’",label:"Action",color:"var(--text-muted, #6b7280)"}},qe=({filter:s,onChange:a,availableFilters:n})=>{var l,r;const c=(u,o)=>{a({...s,[u]:o})};return e.jsxs("div",{className:"nice-audit-filters",children:[e.jsxs("div",{className:"nice-audit-filter-group",children:[e.jsx("label",{children:"Date Range"}),e.jsxs("div",{className:"nice-audit-date-range",children:[e.jsx("input",{type:"date",value:((l=s.startDate)==null?void 0:l.toISOString().split("T")[0])||"",onChange:u=>c("startDate",u.target.value?new Date(u.target.value):void 0)}),e.jsx("span",{children:"to"}),e.jsx("input",{type:"date",value:((r=s.endDate)==null?void 0:r.toISOString().split("T")[0])||"",onChange:u=>c("endDate",u.target.value?new Date(u.target.value):void 0)})]})]}),e.jsxs("div",{className:"nice-audit-filter-group",children:[e.jsx("label",{children:"Actions"}),e.jsx("div",{className:"nice-audit-action-chips",children:Object.keys(le).slice(0,8).map(u=>{var F;const o=le[u],p=(F=s.actions)==null?void 0:F.includes(u);return e.jsxs("button",{type:"button",className:`nice-audit-chip ${p?"nice-audit-chip--selected":""}`,style:{"--chip-color":o.color},onClick:()=>{const z=s.actions||[];c("actions",p?z.filter(g=>g!==u):[...z,u])},children:[e.jsx("span",{className:"nice-audit-chip-icon",children:o.icon}),o.label]},u)})})]}),e.jsxs("div",{className:"nice-audit-filter-group",children:[e.jsx("label",{children:"Search"}),e.jsx("input",{type:"text",className:"nice-audit-search",placeholder:"Search entries...",value:s.searchQuery||"",onChange:u=>c("searchQuery",u.target.value||void 0)})]})]})},Ve=({changes:s})=>{if(!s.length)return null;const a=(n,c)=>c||(n==null?"(empty)":typeof n=="object"?JSON.stringify(n,null,2):String(n));return e.jsx("div",{className:"nice-audit-diff",children:s.map((n,c)=>e.jsxs("div",{className:"nice-audit-diff-row",children:[e.jsx("span",{className:"nice-audit-diff-field",children:n.field}),e.jsxs("div",{className:"nice-audit-diff-values",children:[e.jsx("span",{className:"nice-audit-diff-old",children:a(n.oldValue,n.displayOldValue)}),e.jsx("span",{className:"nice-audit-diff-arrow",children:"β†’"}),e.jsx("span",{className:"nice-audit-diff-new",children:a(n.newValue,n.displayNewValue)})]})]},c))})},Be=({entry:s,showDiff:a,renderActionIcon:n,renderUser:c,onClick:l})=>{const[r,u]=i.useState(!1),o=le[s.action]||le.custom;return e.jsxs("div",{className:`nice-audit-timeline-entry nice-audit-timeline-entry--${s.severity||"info"}`,onClick:l,role:l?"button":void 0,tabIndex:l?0:void 0,children:[e.jsx("div",{className:"nice-audit-timeline-marker",style:{"--marker-color":o.color},children:n?n(s.action):o.icon}),e.jsxs("div",{className:"nice-audit-timeline-content",children:[e.jsxs("div",{className:"nice-audit-timeline-header",children:[e.jsx("span",{className:"nice-audit-timeline-action",children:s.actionLabel||o.label}),e.jsxs("span",{className:"nice-audit-timeline-entity",children:[s.entityType," ",s.entityName&&`"${s.entityName}"`]}),e.jsx("span",{className:"nice-audit-timeline-time",children:new Date(s.timestamp).toLocaleString()})]}),e.jsx("div",{className:"nice-audit-timeline-user",children:c?c(s):e.jsxs(e.Fragment,{children:[s.userAvatar&&e.jsx("img",{src:s.userAvatar,alt:"",className:"nice-audit-avatar"}),e.jsx("span",{className:"nice-audit-username",children:s.userName}),s.userRole&&e.jsx("span",{className:"nice-audit-role",children:s.userRole})]})}),s.notes&&e.jsx("div",{className:"nice-audit-timeline-notes",children:s.notes}),a&&s.changes&&s.changes.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"nice-audit-expand-btn",onClick:p=>{p.stopPropagation(),u(!r)},children:r?"β–Ό Hide changes":`β–Ά Show ${s.changes.length} changes`}),r&&e.jsx(Ve,{changes:s.changes})]}),s.ipAddress&&e.jsxs("div",{className:"nice-audit-timeline-meta",children:[e.jsxs("span",{children:["IP: ",s.ipAddress]}),s.location&&e.jsxs("span",{children:["β€’ ",s.location]})]})]})]})},He=({entries:s,showDiff:a,onEntryClick:n})=>e.jsxs("table",{className:"nice-audit-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Action"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Entity"}),e.jsx("th",{children:"Changes"}),e.jsx("th",{children:"IP Address"})]})}),e.jsx("tbody",{children:s.map(c=>{const l=le[c.action]||le.custom;return e.jsxs("tr",{className:`nice-audit-row nice-audit-row--${c.severity||"info"}`,onClick:()=>n==null?void 0:n(c),role:n?"button":void 0,children:[e.jsx("td",{className:"nice-audit-cell-time",children:new Date(c.timestamp).toLocaleString()}),e.jsx("td",{children:e.jsxs("span",{className:"nice-audit-action-badge",style:{"--badge-color":l.color},children:[l.icon," ",c.actionLabel||l.label]})}),e.jsxs("td",{className:"nice-audit-cell-user",children:[c.userAvatar&&e.jsx("img",{src:c.userAvatar,alt:"",className:"nice-audit-avatar-sm"}),c.userName]}),e.jsxs("td",{children:[c.entityType,c.entityName&&`: ${c.entityName}`]}),e.jsx("td",{children:c.changes&&c.changes.length>0?e.jsxs("span",{className:"nice-audit-changes-count",children:[c.changes.length," field(s)"]}):"-"}),e.jsx("td",{className:"nice-audit-cell-ip",children:c.ipAddress||"-"})]},c.id)})})]}),Se=i.forwardRef(({dataSource:s,initialFilter:a={},pageSize:n=50,viewMode:c="timeline",enableExport:l=!0,showDiffs:r=!0,renderActionIcon:u,renderUser:o,onEntryClick:p,onExport:F,title:z="Audit Trail",className:g="",style:S},M)=>{const[L,W]=i.useState([]),[U,G]=i.useState(0),[Y,q]=i.useState(a),[x,D]=i.useState(1),[v,f]=i.useState(!1),[O,b]=i.useState(c),[R,_]=i.useState(!1),E=i.useCallback(async()=>{f(!0);try{const j=await s.fetchEntries(Y,{page:x,pageSize:n});W(j.entries),G(j.totalCount)}finally{f(!1)}},[s,Y,x,n]);i.useEffect(()=>{E()},[E]);const P=i.useCallback(j=>{if(F)F(L,j);else{let $,T;if(j==="json")$=JSON.stringify(L,null,2),T="application/json";else{const m=["Timestamp","Action","User","Entity Type","Entity","IP","Changes"],y=L.map(k=>{var V;return[new Date(k.timestamp).toISOString(),k.action,k.userName,k.entityType,k.entityName||k.entityId,k.ipAddress||"",((V=k.changes)==null?void 0:V.length)||0]});$=[m.join(","),...y.map(k=>k.join(","))].join(`
3
+ `),T="text/csv"}const K=new Blob([$],{type:T}),A=URL.createObjectURL(K),N=document.createElement("a");N.href=A,N.download=`audit-trail-${Date.now()}.${j}`,N.click(),URL.revokeObjectURL(A)}},[L,F]);i.useImperativeHandle(M,()=>({refresh:E,setFilter:j=>{q(j),D(1)},getEntries:()=>L}));const J=Math.ceil(U/n);return e.jsxs("div",{className:`nice-audit-trail ${g}`,style:S,children:[e.jsxs("div",{className:"nice-audit-header",children:[e.jsx("h3",{className:"nice-audit-title",children:z}),e.jsxs("div",{className:"nice-audit-header-actions",children:[e.jsx("button",{type:"button",className:`nice-audit-view-btn ${O==="timeline"?"nice-audit-view-btn--active":""}`,onClick:()=>b("timeline"),title:"Timeline view",children:"≑"}),e.jsx("button",{type:"button",className:`nice-audit-view-btn ${O==="table"?"nice-audit-view-btn--active":""}`,onClick:()=>b("table"),title:"Table view",children:"⊞"}),e.jsx("button",{type:"button",className:`nice-audit-filter-btn ${R?"nice-audit-filter-btn--active":""}`,onClick:()=>_(!R),children:"πŸ” Filter"}),l&&e.jsxs("div",{className:"nice-audit-export-dropdown",children:[e.jsx("button",{type:"button",className:"nice-audit-export-btn",children:"↓ Export"}),e.jsxs("div",{className:"nice-audit-export-menu",children:[e.jsx("button",{type:"button",onClick:()=>P("csv"),children:"Export as CSV"}),e.jsx("button",{type:"button",onClick:()=>P("json"),children:"Export as JSON"})]})]})]})]}),R&&e.jsx(qe,{filter:Y,onChange:q}),e.jsxs("div",{className:"nice-audit-stats",children:[e.jsxs("span",{children:["Showing ",L.length," of ",U," entries"]}),Y.startDate&&Y.endDate&&e.jsxs("span",{className:"nice-audit-date-indicator",children:[Y.startDate.toLocaleDateString()," - ",Y.endDate.toLocaleDateString()]})]}),e.jsxs("div",{className:`nice-audit-content ${v?"nice-audit-content--loading":""}`,children:[v&&e.jsx("div",{className:"nice-audit-loader",children:e.jsx("div",{className:"nice-audit-spinner"})}),O==="timeline"?e.jsx("div",{className:"nice-audit-timeline",children:L.map(j=>e.jsx(Be,{entry:j,showDiff:r,renderActionIcon:u,renderUser:o,onClick:p?()=>p(j):void 0},j.id))}):e.jsx(He,{entries:L,showDiff:r,onEntryClick:p}),L.length===0&&!v&&e.jsx("div",{className:"nice-audit-empty",children:"No audit entries found matching the current filters."})]}),J>1&&e.jsxs("div",{className:"nice-audit-pagination",children:[e.jsx("button",{type:"button",disabled:x===1,onClick:()=>D(x-1),children:"Previous"}),e.jsxs("span",{children:["Page ",x," of ",J]}),e.jsx("button",{type:"button",disabled:x===J,onClick:()=>D(x+1),children:"Next"})]})]})});Se.displayName="NiceAuditTrail";const te={general:{label:"General",color:"var(--text-muted, #6b7280)",icon:"πŸ“„"},liability:{label:"Liability",color:"var(--color-error, #ef4444)",icon:"⚠️"},payment:{label:"Payment",color:"var(--color-success, #10b981)",icon:"πŸ’°"},termination:{label:"Termination",color:"var(--color-warning, #f59e0b)",icon:"β›”"},confidentiality:{label:"Confidentiality",color:"var(--color-accent, #8b5cf6)",icon:"πŸ”’"},compliance:{label:"Compliance",color:"var(--color-primary, #3b82f6)",icon:"βœ“"},custom:{label:"Custom",color:"var(--text-muted, #64748b)",icon:"✎"}},ze={draft:{label:"Draft",color:"var(--text-muted, #6b7280)"},pending_review:{label:"Pending Review",color:"var(--color-warning, #f59e0b)"},approved:{label:"Approved",color:"var(--color-success, #10b981)"},rejected:{label:"Rejected",color:"var(--color-error, #ef4444)"},signed:{label:"Signed",color:"var(--color-accent, #8b5cf6)"}},Ge=({clauses:s,onInsert:a})=>{const[n,c]=i.useState(""),[l,r]=i.useState("all"),u=s.filter(o=>{const p=n===""||o.name.toLowerCase().includes(n.toLowerCase())||o.content.toLowerCase().includes(n.toLowerCase()),F=l==="all"||o.category===l;return p&&F});return e.jsxs("div",{className:"nice-contract-library",children:[e.jsxs("div",{className:"nice-contract-library-header",children:[e.jsx("h4",{children:"Clause Library"}),e.jsx("input",{type:"text",placeholder:"Search clauses...",value:n,onChange:o=>c(o.target.value),className:"nice-contract-library-search"})]}),e.jsxs("div",{className:"nice-contract-library-categories",children:[e.jsx("button",{type:"button",className:`nice-contract-category-btn ${l==="all"?"nice-contract-category-btn--active":""}`,onClick:()=>r("all"),children:"All"}),Object.keys(te).map(o=>e.jsxs("button",{type:"button",className:`nice-contract-category-btn ${l===o?"nice-contract-category-btn--active":""}`,onClick:()=>r(o),style:{"--cat-color":te[o].color},children:[te[o].icon," ",te[o].label]},o))]}),e.jsxs("div",{className:"nice-contract-library-list",children:[u.map(o=>e.jsxs("div",{className:"nice-contract-library-item",children:[e.jsxs("div",{className:"nice-contract-library-item-header",children:[e.jsx("span",{className:"nice-contract-library-item-name",children:o.name}),e.jsx("span",{className:"nice-contract-library-item-cat",style:{"--cat-color":te[o.category].color},children:te[o.category].icon})]}),o.description&&e.jsx("p",{className:"nice-contract-library-item-desc",children:o.description}),e.jsx("button",{type:"button",className:"nice-contract-library-insert",onClick:()=>a(o),children:"+ Insert"})]},o.id)),u.length===0&&e.jsx("div",{className:"nice-contract-library-empty",children:"No matching clauses"})]})]})},Je=({variables:s,definitions:a,onChange:n})=>e.jsxs("div",{className:"nice-contract-variables",children:[e.jsx("h4",{children:"Variables"}),e.jsx("div",{className:"nice-contract-variables-list",children:a.map(c=>e.jsxs("div",{className:"nice-contract-variable",children:[e.jsxs("label",{children:[c.name,c.required&&e.jsx("span",{className:"nice-contract-required",children:"*"})]}),c.type==="select"&&c.options?e.jsxs("select",{value:s[c.name]||c.defaultValue||"",onChange:l=>n(c.name,l.target.value),children:[e.jsx("option",{value:"",children:"Select..."}),c.options.map(l=>e.jsx("option",{value:l,children:l},l))]}):c.type==="date"?e.jsx("input",{type:"date",value:s[c.name]||c.defaultValue||"",onChange:l=>n(c.name,l.target.value)}):e.jsx("input",{type:c.type==="number"||c.type==="currency"?"number":"text",value:s[c.name]||c.defaultValue||"",placeholder:c.placeholder,onChange:l=>n(c.name,l.target.value)})]},c.name))})]}),We=({section:s,variables:a,readOnly:n,onToggle:c,onRemoveClause:l,onMoveClause:r})=>{const u=o=>o.replace(/\{\{(\w+)\}\}/g,(p,F)=>a[F]||`[${F}]`);return e.jsxs("div",{className:`nice-contract-section ${s.collapsed?"nice-contract-section--collapsed":""}`,children:[e.jsxs("div",{className:"nice-contract-section-header",onClick:c,children:[e.jsx("span",{className:"nice-contract-section-toggle",children:s.collapsed?"β–Ά":"β–Ό"}),e.jsx("h3",{children:s.title}),e.jsxs("span",{className:"nice-contract-section-count",children:[s.clauses.length," clause(s)"]})]}),!s.collapsed&&e.jsxs("div",{className:"nice-contract-section-content",children:[s.clauses.map((o,p)=>e.jsxs("div",{className:"nice-contract-clause",children:[e.jsxs("div",{className:"nice-contract-clause-header",children:[e.jsx("span",{className:"nice-contract-clause-cat",style:{"--cat-color":te[o.category].color},children:te[o.category].icon}),e.jsx("span",{className:"nice-contract-clause-name",children:o.name}),o.isRequired&&e.jsx("span",{className:"nice-contract-clause-required",children:"Required"}),!n&&e.jsxs("div",{className:"nice-contract-clause-actions",children:[e.jsx("button",{type:"button",onClick:()=>r(o.id,"up"),disabled:p===0,children:"↑"}),e.jsx("button",{type:"button",onClick:()=>r(o.id,"down"),disabled:p===s.clauses.length-1,children:"↓"}),e.jsx("button",{type:"button",onClick:()=>l(o.id),children:"Γ—"})]})]}),e.jsx("div",{className:"nice-contract-clause-content",dangerouslySetInnerHTML:{__html:u(o.content)}})]},o.id)),s.clauses.length===0&&e.jsx("div",{className:"nice-contract-section-empty",children:"No clauses in this section. Drag clauses here or use the library."})]})]})},Ke=({workflow:s,onAction:a})=>{const[n,c]=i.useState(null),[l,r]=i.useState("");return e.jsxs("div",{className:"nice-contract-workflow",children:[e.jsx("h4",{children:"Approval Workflow"}),e.jsx("div",{className:"nice-contract-workflow-steps",children:s.steps.map((u,o)=>e.jsxs("div",{className:`nice-contract-workflow-step nice-contract-workflow-step--${u.status}`,children:[e.jsxs("div",{className:"nice-contract-workflow-step-header",children:[e.jsx("span",{className:"nice-contract-workflow-step-num",children:o+1}),e.jsx("span",{className:"nice-contract-workflow-step-name",children:u.name}),e.jsx("span",{className:`nice-contract-workflow-step-status nice-contract-workflow-step-status--${u.status}`,children:u.status})]}),e.jsx("div",{className:"nice-contract-workflow-approvers",children:u.approvers.map(p=>e.jsxs("div",{className:"nice-contract-approver",children:[p.avatar&&e.jsx("img",{src:p.avatar,alt:"",className:"nice-contract-approver-avatar"}),e.jsx("span",{children:p.name}),e.jsx("span",{className:"nice-contract-approver-role",children:p.role})]},p.id))}),u.status==="pending"&&s.currentStep===o&&e.jsx("div",{className:"nice-contract-workflow-actions",children:n===u.id?e.jsxs(e.Fragment,{children:[e.jsx("textarea",{placeholder:"Comments (optional)",value:l,onChange:p=>r(p.target.value)}),e.jsxs("div",{className:"nice-contract-workflow-btns",children:[e.jsx("button",{type:"button",className:"nice-contract-btn nice-contract-btn--approve",onClick:()=>{a(u.id,"approve",l),c(null),r("")},children:"βœ“ Approve"}),e.jsx("button",{type:"button",className:"nice-contract-btn nice-contract-btn--reject",onClick:()=>{a(u.id,"reject",l),c(null),r("")},children:"βœ— Reject"}),e.jsx("button",{type:"button",onClick:()=>c(null),children:"Cancel"})]})]}):e.jsx("button",{type:"button",className:"nice-contract-btn",onClick:()=>c(u.id),children:"Review"})})]},u.id))})]})},Ce=i.forwardRef(({document:s,clauseLibrary:a=[],readOnly:n=!1,showClauseLibrary:c=!0,showVersionHistory:l=!1,showComments:r=!1,showWorkflow:u=!0,currentUser:o,onChange:p,onAddClause:F,onRemoveClause:z,onVariableChange:g,onAddComment:S,onApprovalAction:M,onRestoreVersion:L,onSave:W,onExport:U,className:G="",style:Y},q)=>{var N;const[x,D]=i.useState(s),[v,f]=i.useState(c?"library":null),[O,b]=i.useState(((N=x.sections[0])==null?void 0:N.id)||null),_=x.sections.flatMap(m=>m.clauses.flatMap(y=>y.variables||[])).filter((m,y,k)=>k.findIndex(V=>V.name===m.name)===y),E=i.useCallback(m=>{const y={...x,...m,updatedAt:new Date};D(y),p==null||p(y)},[x,p]),P=i.useCallback((m,y)=>{const k=x.sections.map(V=>V.id===y?{...V,clauses:[...V.clauses,{...m,id:`${m.id}-${Date.now()}`}]}:V);E({sections:k}),F==null||F(m,y)},[x,E,F]),J=i.useCallback((m,y)=>{const k=x.sections.map(V=>V.id===y?{...V,clauses:V.clauses.filter(C=>C.id!==m)}:V);E({sections:k}),z==null||z(m,y)},[x,E,z]),j=i.useCallback((m,y,k)=>{const V=x.sections.map(C=>{if(C.id!==m)return C;const Z=C.clauses.findIndex(Q=>Q.id===y);if(Z===-1)return C;const se=k==="up"?Z-1:Z+1;if(se<0||se>=C.clauses.length)return C;const ee=[...C.clauses];return[ee[Z],ee[se]]=[ee[se],ee[Z]],{...C,clauses:ee}});E({sections:V})},[x,E]),$=i.useCallback(m=>{const y=x.sections.map(k=>k.id===m?{...k,collapsed:!k.collapsed}:k);E({sections:y})},[x,E]),T=i.useCallback((m,y)=>{E({variables:{...x.variables,[m]:y}}),g==null||g(m,y)},[x,E,g]),K=i.useCallback(()=>{const m=[];return _.forEach(y=>{y.required&&!x.variables[y.name]&&m.push(`Missing required variable: ${y.name}`)}),x.sections.forEach(y=>{y.clauses.forEach(k=>{k.isRequired&&!k.content&&m.push(`Required clause "${k.name}" is empty`)})}),{valid:m.length===0,errors:m}},[x,_]);i.useImperativeHandle(q,()=>({getDocument:()=>x,insertClause:P,setVariable:T,exportDocument:m=>U==null?void 0:U(m),validate:K}));const A=ze[x.status];return e.jsxs("div",{className:`nice-contract-editor ${G}`,style:Y,children:[e.jsxs("div",{className:"nice-contract-header",children:[e.jsxs("div",{className:"nice-contract-header-info",children:[e.jsx("h2",{className:"nice-contract-title",children:x.title}),e.jsx("span",{className:"nice-contract-status",style:{"--status-color":A.color},children:A.label})]}),e.jsxs("div",{className:"nice-contract-header-actions",children:[W&&!n&&e.jsx("button",{type:"button",className:"nice-contract-btn nice-contract-btn--primary",onClick:()=>W(x),children:"Save"}),U&&e.jsxs("div",{className:"nice-contract-export-dropdown",children:[e.jsx("button",{type:"button",className:"nice-contract-btn",children:"Export β–Ό"}),e.jsxs("div",{className:"nice-contract-export-menu",children:[e.jsx("button",{type:"button",onClick:()=>U("pdf"),children:"PDF"}),e.jsx("button",{type:"button",onClick:()=>U("docx"),children:"Word (.docx)"}),e.jsx("button",{type:"button",onClick:()=>U("html"),children:"HTML"})]})]})]})]}),e.jsxs("div",{className:"nice-contract-toolbar",children:[c&&e.jsx("button",{type:"button",className:`nice-contract-toolbar-btn ${v==="library"?"nice-contract-toolbar-btn--active":""}`,onClick:()=>f(v==="library"?null:"library"),children:"πŸ“š Library"}),e.jsx("button",{type:"button",className:`nice-contract-toolbar-btn ${v==="variables"?"nice-contract-toolbar-btn--active":""}`,onClick:()=>f(v==="variables"?null:"variables"),children:"πŸ”€ Variables"}),u&&x.workflow&&e.jsx("button",{type:"button",className:`nice-contract-toolbar-btn ${v==="workflow"?"nice-contract-toolbar-btn--active":""}`,onClick:()=>f(v==="workflow"?null:"workflow"),children:"βœ“ Workflow"}),l&&e.jsx("button",{type:"button",className:`nice-contract-toolbar-btn ${v==="history"?"nice-contract-toolbar-btn--active":""}`,onClick:()=>f(v==="history"?null:"history"),children:"πŸ“œ History"})]}),e.jsxs("div",{className:"nice-contract-main",children:[v&&e.jsxs("div",{className:"nice-contract-panel",children:[v==="library"&&e.jsx(Ge,{clauses:a,onInsert:m=>O&&P(m,O)}),v==="variables"&&e.jsx(Je,{variables:x.variables,definitions:_,onChange:T}),v==="workflow"&&x.workflow&&e.jsx(Ke,{workflow:x.workflow,onAction:(m,y,k)=>M==null?void 0:M(m,y,k)})]}),e.jsx("div",{className:"nice-contract-document",children:x.sections.map(m=>e.jsx(We,{section:m,variables:x.variables,readOnly:n,onToggle:()=>$(m.id),onRemoveClause:y=>J(y,m.id),onMoveClause:(y,k)=>j(m.id,y,k)},m.id))})]})]})});Ce.displayName="NiceContractEditor";const Xe=[{id:"necessary",label:"Necessary",description:"Essential cookies for site functionality. Cannot be disabled.",required:!0,enabled:!0,cookies:["session_id","csrf_token","consent"]},{id:"analytics",label:"Analytics",description:"Help us understand how visitors interact with our website.",enabled:!1,cookies:["_ga","_gid","_gat"],partners:["Google Analytics","Hotjar"]},{id:"marketing",label:"Marketing",description:"Used to deliver personalized advertisements.",enabled:!1,cookies:["_fbp","_gcl_au","ads_id"],partners:["Facebook","Google Ads","LinkedIn"]},{id:"preferences",label:"Preferences",description:"Remember your settings and preferences.",enabled:!1,cookies:["theme","language","timezone"]},{id:"social",label:"Social Media",description:"Enable social sharing and embedded content.",enabled:!1,cookies:["social_session"],partners:["Twitter","YouTube","Instagram"]}],Ze={title:"Cookie Preferences",description:"We use cookies to enhance your experience. Choose which types of cookies you allow.",acceptAll:"Accept All",rejectAll:"Reject All",customize:"Customize",savePreferences:"Save Preferences",necessary:"Necessary",analytics:"Analytics",marketing:"Marketing",preferences:"Preferences",social:"Social Media",dataRights:"Your Data Rights",exportData:"Export My Data",deleteData:"Delete My Data",pending:"Pending",processing:"Processing",completed:"Completed",close:"Close"},Qe=({option:s,enabled:a,onChange:n})=>e.jsxs("div",{className:"nice-gdpr-option",children:[e.jsxs("div",{className:"nice-gdpr-option-header",children:[e.jsxs("label",{className:"nice-gdpr-option-toggle",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:c=>n(c.target.checked),disabled:s.required}),e.jsx("span",{className:"nice-gdpr-toggle-slider"})]}),e.jsxs("div",{className:"nice-gdpr-option-info",children:[e.jsxs("span",{className:"nice-gdpr-option-label",children:[s.label,s.required&&e.jsx("span",{className:"nice-gdpr-required",children:"Required"})]}),e.jsx("span",{className:"nice-gdpr-option-desc",children:s.description})]})]}),s.partners&&s.partners.length>0&&e.jsxs("div",{className:"nice-gdpr-option-partners",children:[e.jsx("span",{children:"Partners: "}),s.partners.join(", ")]})]}),es=({requests:s,policies:a,onRequest:n,onDownload:c,labels:l})=>e.jsxs("div",{className:"nice-gdpr-rights",children:[e.jsx("h4",{children:l.dataRights}),e.jsxs("div",{className:"nice-gdpr-rights-actions",children:[e.jsxs("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--secondary",onClick:()=>n("export"),children:["πŸ“₯ ",l.exportData]}),e.jsxs("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--danger",onClick:()=>n("delete"),children:["πŸ—‘οΈ ",l.deleteData]})]}),s.length>0&&e.jsxs("div",{className:"nice-gdpr-requests",children:[e.jsx("h5",{children:"Previous Requests"}),s.map(r=>e.jsxs("div",{className:`nice-gdpr-request nice-gdpr-request--${r.status}`,children:[e.jsx("span",{className:"nice-gdpr-request-type",children:r.type}),e.jsx("span",{className:"nice-gdpr-request-date",children:new Date(r.requestedAt).toLocaleDateString()}),e.jsx("span",{className:"nice-gdpr-request-status",children:r.status}),r.status==="completed"&&r.downloadUrl&&e.jsx("button",{type:"button",className:"nice-gdpr-download-btn",onClick:()=>c(r.id),children:"Download"})]},r.id))]}),a.length>0&&e.jsxs("div",{className:"nice-gdpr-policies",children:[e.jsx("h5",{children:"Data Retention"}),e.jsxs("table",{className:"nice-gdpr-policies-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Category"}),e.jsx("th",{children:"Retention"}),e.jsx("th",{children:"Legal Basis"})]})}),e.jsx("tbody",{children:a.map((r,u)=>e.jsxs("tr",{children:[e.jsx("td",{children:r.category}),e.jsxs("td",{children:[r.retentionDays," days"]}),e.jsx("td",{children:r.legalBasis})]},u))})]})]})]}),De=i.forwardRef(({appName:s,companyName:a,options:n=Xe,currentConsent:c=null,retentionPolicies:l=[],dataRequests:r=[],privacyPolicy:u=[],storageKey:o="nice_gdpr_consent",consentVersion:p="1.0",variant:F="banner",position:z="bottom",onConsentChange:g,onDataRequest:S,onDownloadExport:M,privacyPolicyUrl:L,cookiePolicyUrl:W,termsUrl:U,labels:G,className:Y="",style:q},x)=>{const D={...Ze,...G},[v,f]=i.useState(!1),[O,b]=i.useState(!1),[R,_]=i.useState(!1),[E,P]=i.useState(()=>{const N={};return n.forEach(m=>{N[m.id]=(c==null?void 0:c.categories[m.id])??m.enabled}),N});i.useEffect(()=>{(!c||c.version!==p)&&f(!0)},[c,p]);const J=i.useCallback((N,m)=>{const y=m||E;y.necessary=!0;const k={version:p,timestamp:new Date,categories:y,action:N};try{localStorage.setItem(o,JSON.stringify(k))}catch{}P(y),f(!1),b(!1),g==null||g(k)},[E,p,o,g]),j=i.useCallback(()=>{const N={};n.forEach(m=>{N[m.id]=!0}),J("accept_all",N)},[n,J]),$=i.useCallback(()=>{const N={};n.forEach(m=>{N[m.id]=m.required||!1}),J("reject_all",N)},[n,J]),T=i.useCallback(async N=>{S&&await S(N)},[S]);if(i.useImperativeHandle(x,()=>({showBanner:()=>f(!0),hideBanner:()=>f(!1),getConsent:()=>{try{const N=localStorage.getItem(o);return N?JSON.parse(N):null}catch{return null}},revokeConsent:()=>{try{localStorage.removeItem(o)}catch{}f(!0)},openPreferences:()=>{f(!0),b(!0)}})),!v&&F!=="embedded")return null;const K=e.jsxs("div",{className:"nice-gdpr-content",children:[e.jsxs("div",{className:"nice-gdpr-header",children:[e.jsx("div",{className:"nice-gdpr-icon",children:"πŸͺ"}),e.jsxs("div",{className:"nice-gdpr-header-text",children:[e.jsx("h3",{children:D.title}),e.jsx("p",{children:D.description.replace("{app}",s).replace("{company}",a)})]})]}),!O&&!R&&e.jsxs("div",{className:"nice-gdpr-quick-actions",children:[e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--primary",onClick:j,children:D.acceptAll}),e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--secondary",onClick:$,children:D.rejectAll}),e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--link",onClick:()=>b(!0),children:D.customize})]}),O&&!R&&e.jsxs("div",{className:"nice-gdpr-preferences",children:[e.jsx("div",{className:"nice-gdpr-options",children:n.map(N=>e.jsx(Qe,{option:N,enabled:E[N.id],onChange:m=>P(y=>({...y,[N.id]:m}))},N.id))}),e.jsxs("div",{className:"nice-gdpr-pref-actions",children:[e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--primary",onClick:()=>J("custom"),children:D.savePreferences}),e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--link",onClick:()=>_(!0),children:D.dataRights})]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsx(es,{requests:r,policies:l,onRequest:T,onDownload:N=>M==null?void 0:M(N),labels:D}),e.jsx("button",{type:"button",className:"nice-gdpr-btn nice-gdpr-btn--link",onClick:()=>_(!1),children:"← Back to preferences"})]}),e.jsxs("div",{className:"nice-gdpr-footer",children:[L&&e.jsx("a",{href:L,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}),W&&e.jsx("a",{href:W,target:"_blank",rel:"noopener noreferrer",children:"Cookie Policy"}),U&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})]})]}),A=`nice-gdpr-consent nice-gdpr-consent--${F} nice-gdpr-consent--${z} ${Y}`;return F==="modal"?e.jsx("div",{className:"nice-gdpr-overlay",children:e.jsx("div",{className:A,style:q,role:"dialog","aria-modal":"true",children:K})}):e.jsx("div",{className:A,style:q,children:K})});De.displayName="NiceGDPRConsent";const Te={document:"πŸ“„",user:"πŸ‘€",task:"βœ“",project:"πŸ“",setting:"βš™οΈ",help:"❓",action:"⚑",custom:"β€’"},ss=({value:s,onChange:a,onKeyDown:n,placeholder:c,isLoading:l,inputRef:r})=>e.jsxs("div",{className:"nice-search-input-container",children:[e.jsx("span",{className:"nice-search-icon",children:"πŸ”"}),e.jsx("input",{ref:r,type:"text",className:"nice-search-input",placeholder:c,value:s,onChange:u=>a(u.target.value),onKeyDown:n,"aria-label":"Search"}),l&&e.jsx("span",{className:"nice-search-loader"}),s&&!l&&e.jsx("button",{type:"button",className:"nice-search-clear",onClick:()=>a(""),"aria-label":"Clear search",children:"Γ—"})]}),cs=({result:s,isSelected:a,onSelect:n,renderResult:c})=>c?e.jsx("div",{onClick:n,children:c(s,a)}):e.jsxs("div",{className:`nice-search-result ${a?"nice-search-result--selected":""}`,onClick:n,role:"option","aria-selected":a,children:[e.jsx("div",{className:"nice-search-result-icon",children:s.icon||(s.image?e.jsx("img",{src:s.image,alt:""}):Te[s.type])}),e.jsxs("div",{className:"nice-search-result-content",children:[e.jsx("span",{className:"nice-search-result-title",children:s.title}),s.subtitle&&e.jsx("span",{className:"nice-search-result-subtitle",children:s.subtitle}),s.description&&e.jsx("span",{className:"nice-search-result-desc",children:s.description})]}),e.jsxs("div",{className:"nice-search-result-meta",children:[e.jsx("span",{className:"nice-search-result-source",children:s.source}),e.jsx("span",{className:"nice-search-result-type",children:s.type})]}),s.actions&&s.actions.length>0&&e.jsx("div",{className:"nice-search-result-actions",children:s.actions.map(l=>e.jsx("button",{type:"button",className:"nice-search-action-btn",onClick:r=>{r.stopPropagation(),l.onClick()},title:l.label,children:l.icon||l.label},l.id))})]}),is=({categories:s,selected:a,onSelect:n})=>e.jsxs("div",{className:"nice-search-categories",children:[e.jsx("button",{type:"button",className:`nice-search-category ${a===null?"nice-search-category--active":""}`,onClick:()=>n(null),children:"All"}),s.map(c=>e.jsxs("button",{type:"button",className:`nice-search-category ${a===c.id?"nice-search-category--active":""}`,onClick:()=>n(c.id),children:[c.icon&&e.jsx("span",{className:"nice-search-category-icon",children:c.icon}),c.label,c.count!==void 0&&e.jsx("span",{className:"nice-search-category-count",children:c.count})]},c.id))]}),as=({searches:s,onSelect:a,onClear:n,label:c,clearLabel:l})=>e.jsxs("div",{className:"nice-search-recent",children:[e.jsxs("div",{className:"nice-search-recent-header",children:[e.jsx("span",{children:c}),e.jsx("button",{type:"button",onClick:n,children:l})]}),e.jsx("div",{className:"nice-search-recent-list",children:s.map((r,u)=>e.jsxs("button",{type:"button",className:"nice-search-recent-item",onClick:()=>a(r.query),children:[e.jsx("span",{className:"nice-search-recent-icon",children:"πŸ•’"}),e.jsx("span",{className:"nice-search-recent-query",children:r.query})]},u))})]}),ts={placeholder:"Search...",recent:"Recent Searches",noResults:"No results found for",searching:"Searching...",clearRecent:"Clear",categories:"Categories",filters:"Filters"},Ie=i.forwardRef(({sources:s,placeholder:a,minQueryLength:n=2,debounceMs:c=300,showCategories:l=!0,filters:r=[],showRecent:u=!0,maxRecent:o=5,showShortcuts:p=!0,hotkey:F="k",onResultSelect:z,onSearch:g,onClose:S,renderResult:M,renderEmpty:L,defaultOpen:W=!1,open:U,variant:G="modal",labels:Y,className:q="",style:x},D)=>{const v={...ts,...Y},f=i.useRef(null),O=i.useRef(),[b,R]=i.useState(W),[_,E]=i.useState(""),[P,J]=i.useState([]),[j,$]=i.useState(!1),[T,K]=i.useState(0),[A,N]=i.useState(null),[m,y]=i.useState([]),k=U!==void 0?U:b;i.useEffect(()=>{try{const h=localStorage.getItem("nice_recent_searches");h&&y(JSON.parse(h))}catch{}},[]);const V=i.useCallback((h,I)=>{const ie=[{query:h,timestamp:new Date,resultCount:I},...m.filter(ne=>ne.query!==h)].slice(0,o);y(ie);try{localStorage.setItem("nice_recent_searches",JSON.stringify(ie))}catch{}},[m,o]),C=i.useCallback(async h=>{if(h.length<n){J([]);return}$(!0);try{const I=s.map(async ie=>{try{return(await ie.search(h)).map(re=>({...re,source:ie.name,relevanceScore:re.relevanceScore*(ie.priority||1)}))}catch{return[]}}),B=(await Promise.all(I)).flat();B.sort((ie,ne)=>ne.relevanceScore-ie.relevanceScore),J(B),K(0),g==null||g(h,B),B.length>0&&V(h,B.length)}finally{$(!1)}},[s,n,g,V]),Z=i.useCallback(h=>{E(h),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{C(h)},c)},[C,c]),se=i.useCallback(h=>{switch(h.key){case"ArrowDown":h.preventDefault(),K(I=>Math.min(I+1,P.length-1));break;case"ArrowUp":h.preventDefault(),K(I=>Math.max(I-1,0));break;case"Enter":h.preventDefault(),P[T]&&(z==null||z(P[T]),R(!1),S==null||S());break;case"Escape":h.preventDefault(),R(!1),S==null||S();break}},[P,T,z,S]);i.useEffect(()=>{const h=I=>{(I.metaKey||I.ctrlKey)&&I.key===F&&(I.preventDefault(),R(!0),setTimeout(()=>{var B;return(B=f.current)==null?void 0:B.focus()},0))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[F]),i.useEffect(()=>{k&&setTimeout(()=>{var h;return(h=f.current)==null?void 0:h.focus()},0)},[k]);const ee=A?P.filter(h=>h.type===A):P,Q=Array.from(new Set(P.map(h=>h.type))).map(h=>({id:h,label:h.charAt(0).toUpperCase()+h.slice(1),icon:Te[h],count:P.filter(I=>I.type===h).length}));if(i.useImperativeHandle(D,()=>({open:()=>R(!0),close:()=>{R(!1),S==null||S()},focus:()=>{var h;return(h=f.current)==null?void 0:h.focus()},clear:()=>{E(""),J([])},search:async h=>{E(h),await C(h)}})),!k&&G!=="inline")return null;const d=e.jsxs("div",{className:"nice-search-content",children:[e.jsx(ss,{value:_,onChange:Z,onKeyDown:se,placeholder:a||v.placeholder,isLoading:j,inputRef:f}),l&&Q.length>1&&_.length>=n&&e.jsx(is,{categories:Q,selected:A,onSelect:N}),e.jsxs("div",{className:"nice-search-results",role:"listbox",children:[j&&_.length>=n&&e.jsx("div",{className:"nice-search-loading",children:v.searching}),!j&&_.length>=n&&ee.length===0&&e.jsx("div",{className:"nice-search-empty",children:L?L(_):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-search-empty-icon",children:"πŸ”"}),e.jsxs("span",{children:[v.noResults,' "',_,'"']})]})}),ee.map((h,I)=>e.jsx(cs,{result:h,isSelected:I===T,onSelect:()=>{z==null||z(h),R(!1),S==null||S()},renderResult:M},h.id))]}),u&&_.length<n&&m.length>0&&e.jsx(as,{searches:m,onSelect:h=>{E(h),C(h)},onClear:()=>{y([]),localStorage.removeItem("nice_recent_searches")},label:v.recent,clearLabel:v.clearRecent}),p&&e.jsxs("div",{className:"nice-search-shortcuts",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"↑"}),e.jsx("kbd",{children:"↓"})," Navigate"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"↡"})," Select"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"Esc"})," Close"]})]})]});return G==="modal"?e.jsx("div",{className:"nice-search-overlay",onClick:()=>{R(!1),S==null||S()},children:e.jsx("div",{className:`nice-global-search nice-global-search--modal ${q}`,style:x,onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true",children:d})}):e.jsx("div",{className:`nice-global-search nice-global-search--${G} ${q}`,style:x,children:d})});Ie.displayName="NiceGlobalSearch";const ns={title:"Invoice Designer",templates:"Templates",elements:"Elements",properties:"Properties",preview:"Preview",export:"Export",save:"Save",addElement:"Add Element",deleteElement:"Delete",duplicateElement:"Duplicate",lockElement:"Lock",unlockElement:"Unlock",undo:"Undo",redo:"Redo",zoom:"Zoom",grid:"Grid",snap:"Snap",noSelection:"Select an element to edit",lineItems:"Line Items",addLineItem:"Add Item",removeLineItem:"Remove"},ve={id:"default",name:"Standard Invoice",category:"standard",pageSize:"a4",orientation:"portrait",margins:{top:40,right:40,bottom:40,left:40},elements:[{id:"logo",type:"image",x:40,y:40,width:150,height:60,field:"seller.logo"},{id:"seller-name",type:"field",x:40,y:110,width:200,height:24,field:"seller.name",style:{fontSize:18,fontWeight:"bold"}},{id:"seller-address",type:"field",x:40,y:140,width:200,height:60,field:"seller.address"},{id:"invoice-title",type:"text",x:400,y:40,width:150,height:40,content:"INVOICE",style:{fontSize:32,fontWeight:"bold"}},{id:"invoice-number",type:"field",x:400,y:90,width:150,height:20,field:"invoiceNumber"},{id:"invoice-date",type:"field",x:400,y:115,width:150,height:20,field:"date"},{id:"due-date",type:"field",x:400,y:140,width:150,height:20,field:"dueDate"},{id:"buyer-name",type:"field",x:40,y:220,width:200,height:24,field:"buyer.name",style:{fontWeight:"bold"}},{id:"buyer-address",type:"field",x:40,y:250,width:200,height:60,field:"buyer.address"},{id:"items-table",type:"table",x:40,y:340,width:520,height:200,field:"items"},{id:"subtotal",type:"subtotal",x:400,y:560,width:160,height:24,field:"subtotal"},{id:"tax",type:"tax",x:400,y:590,width:160,height:24,field:"taxAmount"},{id:"total",type:"total",x:400,y:620,width:160,height:30,field:"total",style:{fontSize:20,fontWeight:"bold"}},{id:"notes",type:"field",x:40,y:680,width:300,height:60,field:"notes"},{id:"bank-details",type:"field",x:40,y:760,width:300,height:60,field:"bankDetails"}]},ls=[{key:"invoiceNumber",label:"Invoice Number",type:"text"},{key:"date",label:"Invoice Date",type:"date"},{key:"dueDate",label:"Due Date",type:"date"},{key:"seller.name",label:"Seller Name",type:"text"},{key:"seller.address",label:"Seller Address",type:"text"},{key:"seller.taxId",label:"Seller Tax ID",type:"text"},{key:"seller.logo",label:"Seller Logo",type:"text"},{key:"buyer.name",label:"Buyer Name",type:"text"},{key:"buyer.address",label:"Buyer Address",type:"text"},{key:"buyer.taxId",label:"Buyer Tax ID",type:"text"},{key:"items",label:"Line Items",type:"text"},{key:"subtotal",label:"Subtotal",type:"currency"},{key:"taxAmount",label:"Tax Amount",type:"currency"},{key:"discount",label:"Discount",type:"currency"},{key:"total",label:"Total",type:"currency"},{key:"currency",label:"Currency",type:"text"},{key:"notes",label:"Notes",type:"text"},{key:"terms",label:"Terms",type:"text"},{key:"bankDetails",label:"Bank Details",type:"text"}],rs=[{type:"text",icon:"T",label:"Text"},{type:"field",icon:"πŸ“‹",label:"Data Field"},{type:"image",icon:"πŸ–ΌοΈ",label:"Image"},{type:"table",icon:"πŸ“Š",label:"Table"},{type:"divider",icon:"β€”",label:"Divider"},{type:"qrcode",icon:"⬛",label:"QR Code"},{type:"barcode",icon:"|||",label:"Barcode"},{type:"signature",icon:"✍️",label:"Signature"},{type:"shape",icon:"⬜",label:"Shape"}],ge=()=>`el-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,je=(s,a)=>a.split(".").reduce((n,c)=>{if(n&&typeof n=="object"&&c in n)return n[c]},s),he=(s,a="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:a}).format(s),_e=i.forwardRef(function(a,n){const{template:c,data:l={},templates:r=[],dataFields:u=ls,showGrid:o=!0,gridSize:p=10,snapToGrid:F=!0,showRulers:z=!0,readOnly:g=!1,labels:S,onChange:M,onExport:L,onSave:W,className:U="",...G}=a,Y=i.useRef(null),q=i.useRef(null);i.useId();const x=i.useMemo(()=>({...ns,...S}),[S]),[D,v]=i.useState(c||ve),[f,O]=i.useState(null),[b,R]=i.useState("elements"),[_,E]=i.useState(100),[P,J]=i.useState(o),[j,$]=i.useState(F),[T,K]=i.useState([]),[A,N]=i.useState(-1),[m,y]=i.useState(null),[k,V]=i.useState({x:0,y:0}),C=i.useMemo(()=>D.elements.find(t=>t.id===f)||null,[D.elements,f]),Z=i.useCallback(t=>{K(w=>[...w.slice(0,A+1),t]),N(w=>w+1)},[A]),se=i.useCallback(()=>{A>0&&(N(t=>t-1),v(T[A-1]))},[T,A]),ee=i.useCallback(()=>{A<T.length-1&&(N(t=>t+1),v(T[A+1]))},[T,A]),Q=i.useCallback(t=>{v(w=>{const H=t(w);return Z(H),M==null||M(H),H})},[M,Z]),d=i.useCallback(t=>{if(g)return;const w={id:ge(),type:t,x:100,y:100,width:t==="divider"?200:120,height:t==="divider"?2:t==="table"?150:40,content:t==="text"?"New Text":void 0};Q(H=>({...H,elements:[...H.elements,w]})),O(w.id)},[g,Q]),h=i.useCallback(t=>{g||(Q(w=>({...w,elements:w.elements.filter(H=>H.id!==t)})),f===t&&O(null))},[g,f,Q]),I=i.useCallback(t=>{if(g)return;const w=D.elements.find(X=>X.id===t);if(!w)return;const H={...w,id:ge(),x:w.x+20,y:w.y+20};Q(X=>({...X,elements:[...X.elements,H]})),O(H.id)},[g,D.elements,Q]),B=i.useCallback((t,w)=>{g||Q(H=>({...H,elements:H.elements.map(X=>X.id===t?{...X,...w}:X)}))},[g,Q]),ie=i.useCallback((t,w)=>{if(g)return;const H=D.elements.find(ce=>ce.id===w);if(!H||H.locked)return;y(w),O(w);const X=t.target.getBoundingClientRect();V({x:t.clientX-X.left,y:t.clientY-X.top})},[g,D.elements]),ne=i.useCallback(t=>{if(!m||!q.current)return;const w=q.current.getBoundingClientRect();let H=(t.clientX-w.left-k.x)/_*100,X=(t.clientY-w.top-k.y)/_*100;j&&(H=Math.round(H/p)*p,X=Math.round(X/p)*p),B(m,{x:H,y:X})},[m,k,p,j,B,_]),re=i.useCallback(()=>{y(null)},[]),Ae=i.useCallback(t=>{const w=r.find(H=>H.id===t);w&&(v(w),Z(w),M==null||M(w))},[r,M,Z]),ue=i.useCallback(t=>{L==null||L(t)},[L]),Le=i.useCallback(()=>{W==null||W(D)},[W,D]),$e=i.useCallback(t=>{if(!t.field)return"";const w=je(l,t.field);return w==null?`{${t.field}}`:t.type==="total"||t.type==="subtotal"||t.type==="tax"?he(Number(w),l.currency):String(w)},[l]);i.useImperativeHandle(n,()=>({getTemplate:()=>D,setTemplate:t=>{v(t),Z(t)},export:ue,addElement:d,removeSelected:()=>{f&&h(f)},undo:se,redo:ee,getElement:()=>Y.current}),[D,Z,ue,d,h,f,se,ee]);const Fe=t=>{var xe,be;const w=t.id===f,H=t.id===m,X={position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,...t.style};let ce=null;switch(t.type){case"text":ce=t.content||"Text";break;case"field":case"total":case"subtotal":case"tax":ce=$e(t);break;case"image":{const ae=t.field?je(l,t.field):t.content;ce=ae?e.jsx("img",{src:ae,alt:""}):e.jsx("span",{className:"nice-invoice-placeholder",children:"πŸ“·"});break}case"table":ce=e.jsxs("div",{className:"nice-invoice-table-preview",children:[e.jsxs("div",{className:"nice-invoice-table-header",children:[e.jsx("span",{children:"Description"}),e.jsx("span",{children:"Qty"}),e.jsx("span",{children:"Price"}),e.jsx("span",{children:"Total"})]}),(l.items||[]).slice(0,3).map(ae=>e.jsxs("div",{className:"nice-invoice-table-row",children:[e.jsx("span",{children:ae.description}),e.jsx("span",{children:ae.quantity}),e.jsx("span",{children:he(ae.unitPrice,l.currency)}),e.jsx("span",{children:he(ae.total,l.currency)})]},ae.id)),(((xe=l.items)==null?void 0:xe.length)||0)>3&&e.jsxs("div",{className:"nice-invoice-table-more",children:["+",(((be=l.items)==null?void 0:be.length)||0)-3," more items"]})]});break;case"divider":ce=e.jsx("hr",{});break;case"qrcode":ce=e.jsx("div",{className:"nice-invoice-qrcode",children:"QR"});break;case"barcode":ce=e.jsx("div",{className:"nice-invoice-barcode",children:"|||||||||||"});break;case"signature":ce=e.jsx("div",{className:"nice-invoice-signature",children:"Signature"});break;case"shape":ce=null;break}return e.jsxs("div",{className:`nice-invoice-element nice-invoice-element--${t.type} ${w?"nice-invoice-element--selected":""} ${H?"nice-invoice-element--dragging":""} ${t.locked?"nice-invoice-element--locked":""}`,style:X,onMouseDown:ae=>ie(ae,t.id),onClick:()=>O(t.id),children:[ce,w&&!g&&e.jsxs("div",{className:"nice-invoice-element-handles",children:[e.jsx("div",{className:"nice-invoice-handle nice-invoice-handle--nw"}),e.jsx("div",{className:"nice-invoice-handle nice-invoice-handle--ne"}),e.jsx("div",{className:"nice-invoice-handle nice-invoice-handle--sw"}),e.jsx("div",{className:"nice-invoice-handle nice-invoice-handle--se"})]})]},t.id)};return e.jsxs("div",{ref:Y,className:`nice-invoice-designer ${U}`,...G,children:[e.jsxs("div",{className:"nice-invoice-toolbar",children:[e.jsxs("div",{className:"nice-invoice-toolbar-left",children:[e.jsx("button",{type:"button",className:"nice-invoice-toolbar-btn",onClick:se,disabled:A<=0,title:x.undo,children:"↩"}),e.jsx("button",{type:"button",className:"nice-invoice-toolbar-btn",onClick:ee,disabled:A>=T.length-1,title:x.redo,children:"β†ͺ"}),e.jsx("div",{className:"nice-invoice-toolbar-divider"}),e.jsx("button",{type:"button",className:`nice-invoice-toolbar-btn ${P?"nice-invoice-toolbar-btn--active":""}`,onClick:()=>J(!P),title:x.grid,children:"⊞"}),e.jsx("button",{type:"button",className:`nice-invoice-toolbar-btn ${j?"nice-invoice-toolbar-btn--active":""}`,onClick:()=>$(!j),title:x.snap,children:"βŒ–"}),e.jsx("div",{className:"nice-invoice-toolbar-divider"}),e.jsxs("select",{className:"nice-invoice-zoom-select",value:_,onChange:t=>E(Number(t.target.value)),children:[e.jsx("option",{value:50,children:"50%"}),e.jsx("option",{value:75,children:"75%"}),e.jsx("option",{value:100,children:"100%"}),e.jsx("option",{value:125,children:"125%"}),e.jsx("option",{value:150,children:"150%"})]})]}),e.jsxs("div",{className:"nice-invoice-toolbar-right",children:[e.jsx("button",{type:"button",className:"nice-invoice-toolbar-btn nice-invoice-toolbar-btn--primary",onClick:()=>ue("pdf"),children:"PDF"}),e.jsx("button",{type:"button",className:"nice-invoice-toolbar-btn",onClick:()=>ue("print"),children:"πŸ–¨οΈ"}),!g&&e.jsxs("button",{type:"button",className:"nice-invoice-toolbar-btn nice-invoice-toolbar-btn--success",onClick:Le,children:["πŸ’Ύ ",x.save]})]})]}),e.jsxs("div",{className:"nice-invoice-main",children:[e.jsxs("div",{className:"nice-invoice-sidebar",children:[e.jsxs("div",{className:"nice-invoice-sidebar-tabs",children:[e.jsx("button",{type:"button",className:`nice-invoice-sidebar-tab ${b==="templates"?"nice-invoice-sidebar-tab--active":""}`,onClick:()=>R("templates"),children:"πŸ“„"}),e.jsx("button",{type:"button",className:`nice-invoice-sidebar-tab ${b==="elements"?"nice-invoice-sidebar-tab--active":""}`,onClick:()=>R("elements"),children:"⬛"}),e.jsx("button",{type:"button",className:`nice-invoice-sidebar-tab ${b==="properties"?"nice-invoice-sidebar-tab--active":""}`,onClick:()=>R("properties"),children:"βš™οΈ"})]}),e.jsxs("div",{className:"nice-invoice-sidebar-content",children:[b==="templates"&&e.jsxs("div",{className:"nice-invoice-panel",children:[e.jsx("h3",{className:"nice-invoice-panel-title",children:x.templates}),e.jsx("div",{className:"nice-invoice-templates-grid",children:[ve,...r].map(t=>e.jsxs("button",{type:"button",className:`nice-invoice-template-card ${t.id===D.id?"nice-invoice-template-card--active":""}`,onClick:()=>Ae(t.id),children:[e.jsx("div",{className:"nice-invoice-template-preview",children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):e.jsx("div",{className:"nice-invoice-template-placeholder",children:"πŸ“„"})}),e.jsx("span",{className:"nice-invoice-template-name",children:t.name})]},t.id))})]}),b==="elements"&&e.jsxs("div",{className:"nice-invoice-panel",children:[e.jsx("h3",{className:"nice-invoice-panel-title",children:x.elements}),e.jsx("div",{className:"nice-invoice-elements-grid",children:rs.map(t=>e.jsxs("button",{type:"button",className:"nice-invoice-element-btn",onClick:()=>d(t.type),disabled:g,children:[e.jsx("span",{className:"nice-invoice-element-icon",children:t.icon}),e.jsx("span",{className:"nice-invoice-element-label",children:t.label})]},t.type))}),e.jsx("h4",{className:"nice-invoice-panel-subtitle",children:"Data Fields"}),e.jsx("div",{className:"nice-invoice-fields-list",children:u.map(t=>e.jsx("button",{type:"button",className:"nice-invoice-field-btn",onClick:()=>{C&&B(C.id,{field:t.key})},disabled:!C||g,children:t.label},t.key))})]}),b==="properties"&&e.jsxs("div",{className:"nice-invoice-panel",children:[e.jsx("h3",{className:"nice-invoice-panel-title",children:x.properties}),C?e.jsxs("div",{className:"nice-invoice-properties",children:[e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Type"}),e.jsx("input",{type:"text",value:C.type,readOnly:!0})]}),e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"X"}),e.jsx("input",{type:"number",value:C.x,onChange:t=>B(C.id,{x:Number(t.target.value)}),disabled:g})]}),e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Y"}),e.jsx("input",{type:"number",value:C.y,onChange:t=>B(C.id,{y:Number(t.target.value)}),disabled:g})]}),e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Width"}),e.jsx("input",{type:"number",value:C.width,onChange:t=>B(C.id,{width:Number(t.target.value)}),disabled:g})]}),e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Height"}),e.jsx("input",{type:"number",value:C.height,onChange:t=>B(C.id,{height:Number(t.target.value)}),disabled:g})]}),C.type==="text"&&e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Content"}),e.jsx("input",{type:"text",value:C.content||"",onChange:t=>B(C.id,{content:t.target.value}),disabled:g})]}),C.field!==void 0&&e.jsxs("div",{className:"nice-invoice-property",children:[e.jsx("label",{children:"Field"}),e.jsxs("select",{value:C.field||"",onChange:t=>B(C.id,{field:t.target.value}),disabled:g,children:[e.jsx("option",{value:"",children:"None"}),u.map(t=>e.jsx("option",{value:t.key,children:t.label},t.key))]})]}),e.jsxs("div",{className:"nice-invoice-property-actions",children:[e.jsx("button",{type:"button",onClick:()=>I(C.id),disabled:g,children:x.duplicateElement}),e.jsx("button",{type:"button",onClick:()=>B(C.id,{locked:!C.locked}),disabled:g,children:C.locked?x.unlockElement:x.lockElement}),e.jsx("button",{type:"button",className:"nice-invoice-btn--danger",onClick:()=>h(C.id),disabled:g,children:x.deleteElement})]})]}):e.jsx("p",{className:"nice-invoice-no-selection",children:x.noSelection})]})]})]}),e.jsxs("div",{className:"nice-invoice-canvas-area",children:[z&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-invoice-ruler nice-invoice-ruler--horizontal",children:Array.from({length:60},(t,w)=>e.jsx("span",{className:"nice-invoice-ruler-mark",style:{left:w*10*(_/100)},children:w%5===0&&e.jsx("span",{className:"nice-invoice-ruler-label",children:w*10})},w))}),e.jsx("div",{className:"nice-invoice-ruler nice-invoice-ruler--vertical",children:Array.from({length:85},(t,w)=>e.jsx("span",{className:"nice-invoice-ruler-mark",style:{top:w*10*(_/100)},children:w%5===0&&e.jsx("span",{className:"nice-invoice-ruler-label",children:w*10})},w))})]}),e.jsx("div",{ref:q,className:`nice-invoice-canvas ${P?"nice-invoice-canvas--grid":""}`,style:{width:D.orientation==="portrait"?595:842,height:D.orientation==="portrait"?842:595,transform:`scale(${_/100})`,transformOrigin:"top left",backgroundSize:`${p}px ${p}px`},onMouseMove:ne,onMouseUp:re,onMouseLeave:re,onClick:()=>O(null),children:D.elements.map(t=>Fe(t))})]})]})]})});_e.displayName="NiceInvoiceDesigner";const oe={title:"Access Log",filters:"Filters",search:"Search users, IPs...",export:"Export",refresh:"Refresh",details:"Details",stats:"Statistics",map:"Geographic Distribution",timeline:"Timeline",showMore:"Show More",noResults:"No access logs found",eventTypes:{login_success:"Login Success",login_failed:"Login Failed",logout:"Logout",password_change:"Password Change",password_reset:"Password Reset",mfa_enabled:"MFA Enabled",mfa_disabled:"MFA Disabled",mfa_challenged:"MFA Challenge",permission_change:"Permission Change",session_expired:"Session Expired",account_locked:"Account Locked",account_unlocked:"Account Unlocked",api_key_created:"API Key Created",api_key_revoked:"API Key Revoked",token_refresh:"Token Refresh",suspicious_activity:"Suspicious Activity"},riskLevels:{low:"Low",medium:"Medium",high:"High",critical:"Critical"},deviceTypes:{desktop:"Desktop",mobile:"Mobile",tablet:"Tablet",unknown:"Unknown"},columns:{timestamp:"Time",user:"User",event:"Event",ip:"IP Address",location:"Location",device:"Device",risk:"Risk",status:"Status"}},me={login_success:"βœ“",login_failed:"βœ—",logout:"β†—",password_change:"πŸ”‘",password_reset:"πŸ”„",mfa_enabled:"πŸ›‘οΈ",mfa_disabled:"⚠️",mfa_challenged:"πŸ“±",permission_change:"πŸ‘€",session_expired:"⏰",account_locked:"πŸ”’",account_unlocked:"πŸ”“",api_key_created:"πŸ”",api_key_revoked:"❌",token_refresh:"πŸ”ƒ",suspicious_activity:"⚑"},de={low:"var(--color-success, #22c55e)",medium:"var(--color-warning, #f59e0b)",high:"var(--color-error, #ef4444)",critical:"var(--color-accent-hover, #7c3aed)"},Ne={desktop:"πŸ–₯️",mobile:"πŸ“±",tablet:"πŸ“Ÿ",unknown:"❓"},fe=s=>(typeof s=="string"?new Date(s):s).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),ye=s=>{if(!s)return"Unknown";const a=[];return s.city&&a.push(s.city),s.country&&a.push(s.country),a.length>0?a.join(", "):"Unknown"},os=s=>{if(!s)return"Unknown";const a=[];return s.browser&&a.push(s.browser),s.os&&a.push(s.os),a.length>0?a.join(" / "):s.type},ke=s=>s>=80?de.critical:s>=60?de.high:s>=40?de.medium:de.low,ds=(s,a)=>{var n,c,l,r,u;if(a.startDate){const o=typeof a.startDate=="string"?new Date(a.startDate):a.startDate;if((typeof s.timestamp=="string"?new Date(s.timestamp):s.timestamp)<o)return!1}if(a.endDate){const o=typeof a.endDate=="string"?new Date(a.endDate):a.endDate;if((typeof s.timestamp=="string"?new Date(s.timestamp):s.timestamp)>o)return!1}if((n=a.eventTypes)!=null&&n.length&&!a.eventTypes.includes(s.eventType)||(c=a.riskLevels)!=null&&c.length&&!a.riskLevels.includes(s.riskLevel)||a.userId&&s.userId!==a.userId||a.ipAddress&&!s.ipAddress.includes(a.ipAddress)||a.country&&((l=s.location)==null?void 0:l.country)!==a.country||a.successOnly&&!s.success||a.failedOnly&&s.success)return!1;if(a.searchQuery){const o=a.searchQuery.toLowerCase();if(![s.userName,s.userEmail,s.userId,s.ipAddress,(r=s.location)==null?void 0:r.city,(u=s.location)==null?void 0:u.country].filter(Boolean).join(" ").toLowerCase().includes(o))return!1}return!0},Ee=i.forwardRef(function(a,n){var ee,Q;const{entries:c,filter:l={},stats:r,realtime:u=!1,pollingInterval:o=3e4,showMap:p=!1,showStats:F=!0,showDetails:z=!0,pageSize:g=50,labels:S,loading:M=!1,onFilterChange:L,onExport:W,onEntrySelect:U,onBlockIP:G,onRefresh:Y,className:q="",...x}=a,D=i.useRef(null);i.useId();const v=i.useMemo(()=>({...oe,...S,eventTypes:{...oe.eventTypes,...S==null?void 0:S.eventTypes},riskLevels:{...oe.riskLevels,...S==null?void 0:S.riskLevels},deviceTypes:{...oe.deviceTypes,...S==null?void 0:S.deviceTypes},columns:{...oe.columns,...S==null?void 0:S.columns}}),[S]),[f,O]=i.useState(l),[b,R]=i.useState(null),[_,E]=i.useState(g),[P,J]=i.useState(!1),[j,$]=i.useState("table"),T=i.useMemo(()=>c.filter(d=>ds(d,f)),[c,f]),K=i.useMemo(()=>T.slice(0,_),[T,_]),A=i.useMemo(()=>{if(r)return r;const d=new Set(c.map(I=>I.ipAddress)),h=new Set(c.map(I=>{var B;return(B=I.location)==null?void 0:B.country}).filter(Boolean));return{totalEvents:c.length,successfulLogins:c.filter(I=>I.eventType==="login_success").length,failedLogins:c.filter(I=>I.eventType==="login_failed").length,uniqueIPs:d.size,uniqueCountries:h.size,highRiskEvents:c.filter(I=>I.riskLevel==="high"||I.riskLevel==="critical").length,suspiciousActivities:c.filter(I=>I.eventType==="suspicious_activity").length}},[c,r]),N=i.useCallback(d=>{const h={...f,...d};O(h),E(g),L==null||L(h)},[f,L,g]),m=i.useCallback(()=>{O({}),E(g),L==null||L({})},[L,g]),y=i.useCallback(d=>{R(d),U==null||U(d)},[U]),k=i.useCallback(d=>{W==null||W(d)},[W]),V=i.useCallback(()=>{Y==null||Y()},[Y]),C=i.useCallback(()=>{E(d=>d+g)},[g]);i.useImperativeHandle(n,()=>({getFilter:()=>f,applyFilter:N,clearFilters:m,export:k,refresh:V,getSelectedEntry:()=>b,getElement:()=>D.current}),[f,N,m,k,V,b]);const Z=d=>{var h,I;return e.jsxs("tr",{className:`nice-accesslog-row ${(b==null?void 0:b.id)===d.id?"nice-accesslog-row--selected":""} ${d.success?"":"nice-accesslog-row--failed"}`,onClick:()=>y(d),children:[e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--timestamp",children:fe(d.timestamp)}),e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--user",children:e.jsxs("div",{className:"nice-accesslog-user",children:[e.jsx("span",{className:"nice-accesslog-username",children:d.userName||d.userId}),d.userEmail&&e.jsx("span",{className:"nice-accesslog-email",children:d.userEmail})]})}),e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--event",children:e.jsxs("span",{className:`nice-accesslog-event nice-accesslog-event--${d.eventType}`,children:[e.jsx("span",{className:"nice-accesslog-event-icon",children:me[d.eventType]}),v.eventTypes[d.eventType]]})}),e.jsxs("td",{className:"nice-accesslog-cell nice-accesslog-cell--ip",children:[e.jsx("span",{className:"nice-accesslog-ip",children:d.ipAddress}),G&&e.jsx("button",{type:"button",className:"nice-accesslog-block-btn",onClick:B=>{B.stopPropagation(),G(d.ipAddress)},title:"Block IP",children:"🚫"})]}),e.jsxs("td",{className:"nice-accesslog-cell nice-accesslog-cell--location",children:[((h=d.location)==null?void 0:h.countryCode)&&e.jsx("span",{className:"nice-accesslog-flag",children:"🏳️"}),ye(d.location)]}),e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--device",children:e.jsxs("span",{className:"nice-accesslog-device",children:[Ne[((I=d.device)==null?void 0:I.type)||"unknown"],os(d.device)]})}),e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--risk",children:e.jsxs("span",{className:`nice-accesslog-risk nice-accesslog-risk--${d.riskLevel}`,style:{"--risk-color":ke(d.riskScore)},children:[e.jsx("span",{className:"nice-accesslog-risk-score",children:d.riskScore}),e.jsx("span",{className:"nice-accesslog-risk-label",children:v.riskLevels[d.riskLevel]})]})}),e.jsx("td",{className:"nice-accesslog-cell nice-accesslog-cell--status",children:e.jsx("span",{className:`nice-accesslog-status ${d.success?"nice-accesslog-status--success":"nice-accesslog-status--failed"}`,children:d.success?"βœ“":"βœ—"})})]},d.id)},se=d=>e.jsxs("div",{className:`nice-accesslog-timeline-item nice-accesslog-timeline-item--${d.riskLevel}`,onClick:()=>y(d),children:[e.jsx("div",{className:"nice-accesslog-timeline-marker",style:{background:de[d.riskLevel]}}),e.jsxs("div",{className:"nice-accesslog-timeline-content",children:[e.jsxs("div",{className:"nice-accesslog-timeline-header",children:[e.jsxs("span",{className:"nice-accesslog-timeline-event",children:[me[d.eventType]," ",v.eventTypes[d.eventType]]}),e.jsx("span",{className:"nice-accesslog-timeline-time",children:fe(d.timestamp)})]}),e.jsxs("div",{className:"nice-accesslog-timeline-details",children:[e.jsx("span",{children:d.userName||d.userId}),e.jsx("span",{children:"β€’"}),e.jsx("span",{children:d.ipAddress}),e.jsx("span",{children:"β€’"}),e.jsx("span",{children:ye(d.location)})]}),d.flags&&d.flags.length>0&&e.jsx("div",{className:"nice-accesslog-timeline-flags",children:d.flags.map((h,I)=>e.jsx("span",{className:"nice-accesslog-flag-badge",children:h},I))})]})]},d.id);return e.jsxs("div",{ref:D,className:`nice-accesslog ${q}`,...x,children:[e.jsxs("div",{className:"nice-accesslog-header",children:[e.jsxs("div",{className:"nice-accesslog-header-left",children:[e.jsx("h2",{className:"nice-accesslog-title",children:v.title}),u&&e.jsx("span",{className:"nice-accesslog-realtime-badge",children:"● Live"})]}),e.jsxs("div",{className:"nice-accesslog-header-actions",children:[e.jsxs("button",{type:"button",className:"nice-accesslog-btn",onClick:V,disabled:M,children:["πŸ”„ ",v.refresh]}),e.jsxs("div",{className:"nice-accesslog-export-dropdown",children:[e.jsxs("button",{type:"button",className:"nice-accesslog-btn",children:["πŸ“₯ ",v.export]}),e.jsxs("div",{className:"nice-accesslog-export-menu",children:[e.jsx("button",{onClick:()=>k("csv"),children:"CSV"}),e.jsx("button",{onClick:()=>k("json"),children:"JSON"}),e.jsx("button",{onClick:()=>k("pdf"),children:"PDF"})]})]})]})]}),F&&e.jsxs("div",{className:"nice-accesslog-stats",children:[e.jsxs("div",{className:"nice-accesslog-stat",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.totalEvents}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"Total Events"})]}),e.jsxs("div",{className:"nice-accesslog-stat nice-accesslog-stat--success",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.successfulLogins}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"Successful"})]}),e.jsxs("div",{className:"nice-accesslog-stat nice-accesslog-stat--failed",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.failedLogins}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"Failed"})]}),e.jsxs("div",{className:"nice-accesslog-stat",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.uniqueIPs}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"Unique IPs"})]}),e.jsxs("div",{className:"nice-accesslog-stat",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.uniqueCountries}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"Countries"})]}),e.jsxs("div",{className:"nice-accesslog-stat nice-accesslog-stat--warning",children:[e.jsx("span",{className:"nice-accesslog-stat-value",children:A.highRiskEvents}),e.jsx("span",{className:"nice-accesslog-stat-label",children:"High Risk"})]})]}),e.jsxs("div",{className:"nice-accesslog-filters",children:[e.jsxs("div",{className:"nice-accesslog-filters-row",children:[e.jsxs("div",{className:"nice-accesslog-search",children:[e.jsx("span",{className:"nice-accesslog-search-icon",children:"πŸ”"}),e.jsx("input",{type:"text",placeholder:v.search,value:f.searchQuery||"",onChange:d=>N({searchQuery:d.target.value})})]}),e.jsxs("div",{className:"nice-accesslog-filter-quick",children:[e.jsx("button",{type:"button",className:`nice-accesslog-filter-chip ${f.failedOnly?"nice-accesslog-filter-chip--active":""}`,onClick:()=>N({failedOnly:!f.failedOnly,successOnly:!1}),children:"Failed Only"}),e.jsx("button",{type:"button",className:`nice-accesslog-filter-chip ${(ee=f.riskLevels)!=null&&ee.includes("high")||(Q=f.riskLevels)!=null&&Q.includes("critical")?"nice-accesslog-filter-chip--active":""}`,onClick:()=>{var d;return N({riskLevels:(d=f.riskLevels)!=null&&d.includes("high")?[]:["high","critical"]})},children:"High Risk"}),e.jsx("button",{type:"button",className:"nice-accesslog-filter-toggle",onClick:()=>J(!P),children:P?"βˆ’ Less":"+ More"})]})]}),P&&e.jsxs("div",{className:"nice-accesslog-filters-expanded",children:[e.jsxs("div",{className:"nice-accesslog-filter-group",children:[e.jsx("label",{children:"Event Type"}),e.jsx("select",{multiple:!0,value:f.eventTypes||[],onChange:d=>{const h=Array.from(d.target.selectedOptions,I=>I.value);N({eventTypes:h.length?h:void 0})},children:Object.entries(v.eventTypes).map(([d,h])=>e.jsx("option",{value:d,children:h},d))})]}),e.jsxs("div",{className:"nice-accesslog-filter-group",children:[e.jsx("label",{children:"Date Range"}),e.jsxs("div",{className:"nice-accesslog-date-range",children:[e.jsx("input",{type:"date",value:f.startDate?new Date(f.startDate).toISOString().split("T")[0]:"",onChange:d=>N({startDate:d.target.value||void 0})}),e.jsx("span",{children:"to"}),e.jsx("input",{type:"date",value:f.endDate?new Date(f.endDate).toISOString().split("T")[0]:"",onChange:d=>N({endDate:d.target.value||void 0})})]})]}),e.jsxs("div",{className:"nice-accesslog-filter-group",children:[e.jsx("label",{children:"IP Address"}),e.jsx("input",{type:"text",placeholder:"e.g., 192.168",value:f.ipAddress||"",onChange:d=>N({ipAddress:d.target.value||void 0})})]}),e.jsx("button",{type:"button",className:"nice-accesslog-clear-filters",onClick:m,children:"Clear All Filters"})]})]}),e.jsxs("div",{className:"nice-accesslog-tabs",children:[e.jsx("button",{type:"button",className:`nice-accesslog-tab ${j==="table"?"nice-accesslog-tab--active":""}`,onClick:()=>$("table"),children:"πŸ“Š Table"}),e.jsxs("button",{type:"button",className:`nice-accesslog-tab ${j==="timeline"?"nice-accesslog-tab--active":""}`,onClick:()=>$("timeline"),children:["πŸ“… ",v.timeline]}),p&&e.jsxs("button",{type:"button",className:`nice-accesslog-tab ${j==="map"?"nice-accesslog-tab--active":""}`,onClick:()=>$("map"),children:["πŸ—ΊοΈ ",v.map]}),e.jsxs("span",{className:"nice-accesslog-count",children:[T.length," entries"]})]}),e.jsx("div",{className:"nice-accesslog-content",children:M?e.jsxs("div",{className:"nice-accesslog-loading",children:[e.jsx("div",{className:"nice-accesslog-spinner"}),"Loading access logs..."]}):T.length===0?e.jsxs("div",{className:"nice-accesslog-empty",children:[e.jsx("span",{className:"nice-accesslog-empty-icon",children:"πŸ”"}),e.jsx("span",{children:v.noResults})]}):e.jsxs(e.Fragment,{children:[j==="table"&&e.jsx("div",{className:"nice-accesslog-table-wrapper",children:e.jsxs("table",{className:"nice-accesslog-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:v.columns.timestamp}),e.jsx("th",{children:v.columns.user}),e.jsx("th",{children:v.columns.event}),e.jsx("th",{children:v.columns.ip}),e.jsx("th",{children:v.columns.location}),e.jsx("th",{children:v.columns.device}),e.jsx("th",{children:v.columns.risk}),e.jsx("th",{children:v.columns.status})]})}),e.jsx("tbody",{children:K.map(Z)})]})}),j==="timeline"&&e.jsx("div",{className:"nice-accesslog-timeline",children:K.map(se)}),j==="map"&&e.jsx("div",{className:"nice-accesslog-map",children:e.jsx("div",{className:"nice-accesslog-map-placeholder",children:"πŸ—ΊοΈ Geographic visualization would render here"})}),_<T.length&&e.jsxs("button",{type:"button",className:"nice-accesslog-show-more",onClick:C,children:[v.showMore," (",T.length-_," remaining)"]})]})}),z&&b&&e.jsxs("div",{className:"nice-accesslog-detail",children:[e.jsxs("div",{className:"nice-accesslog-detail-header",children:[e.jsx("h3",{children:v.details}),e.jsx("button",{type:"button",className:"nice-accesslog-detail-close",onClick:()=>R(null),children:"βœ•"})]}),e.jsxs("div",{className:"nice-accesslog-detail-content",children:[e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Event ID"}),e.jsx("span",{className:"nice-accesslog-detail-value",children:b.id})]}),e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Timestamp"}),e.jsx("span",{className:"nice-accesslog-detail-value",children:new Date(b.timestamp).toISOString()})]}),e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"User"}),e.jsxs("span",{className:"nice-accesslog-detail-value",children:[b.userName," (",b.userId,")",b.userEmail&&e.jsx("div",{children:b.userEmail})]})]}),e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Event Type"}),e.jsxs("span",{className:"nice-accesslog-detail-value",children:[me[b.eventType]," ",v.eventTypes[b.eventType]]})]}),e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"IP Address"}),e.jsx("span",{className:"nice-accesslog-detail-value",children:b.ipAddress})]}),b.location&&e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Location"}),e.jsxs("span",{className:"nice-accesslog-detail-value",children:[b.location.city,", ",b.location.region,","," ",b.location.country,b.location.latitude&&b.location.longitude&&e.jsxs("div",{className:"nice-accesslog-coords",children:["(",b.location.latitude,", ",b.location.longitude,")"]})]})]}),b.device&&e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Device"}),e.jsxs("span",{className:"nice-accesslog-detail-value",children:[Ne[b.device.type]," ",b.device.os," ",b.device.osVersion,e.jsxs("div",{children:[b.device.browser," ",b.device.browserVersion]}),b.device.fingerprint&&e.jsxs("div",{className:"nice-accesslog-fingerprint",children:["Fingerprint: ",b.device.fingerprint]})]})]}),e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Risk Score"}),e.jsx("span",{className:"nice-accesslog-detail-value",children:e.jsxs("span",{style:{color:ke(b.riskScore)},children:[b.riskScore,"/100 (",v.riskLevels[b.riskLevel],")"]})})]}),b.flags&&b.flags.length>0&&e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Flags"}),e.jsx("span",{className:"nice-accesslog-detail-value",children:b.flags.map((d,h)=>e.jsx("span",{className:"nice-accesslog-flag-badge",children:d},h))})]}),b.details&&Object.keys(b.details).length>0&&e.jsxs("div",{className:"nice-accesslog-detail-row",children:[e.jsx("span",{className:"nice-accesslog-detail-label",children:"Additional Details"}),e.jsx("pre",{className:"nice-accesslog-detail-json",children:JSON.stringify(b.details,null,2)})]})]})]})]})});Ee.displayName="NiceAccessLog";exports.NiceAccessLog=Ee;exports.NiceAuditTrail=Se;exports.NiceContractEditor=Ce;exports.NiceDataExportCenter=we;exports.NiceGDPRConsent=De;exports.NiceGlobalSearch=Ie;exports.NiceInvoiceDesigner=_e;