var o=Object.defineProperty;var c=(a)=>a;function s(a,t){this[a]=c.bind(null,t)}var p=(a,t)=>{for(var r in t)o(a,r,{get:t[r],enumerable:!0,configurable:!0,set:s.bind(t,r)})};var m=(a,t)=>()=>(a&&(t=a(a=0)),t);import{CodeBlock as n,InstallCommand as d}from"@contractspec/lib.design-system";import l from"@contractspec/lib.ui-link";import{ChevronRight as g}from"lucide-react";import{jsx as e,jsxs as i}from"react/jsx-runtime";function u(){return i("div",{className:"space-y-8",children:[i("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"Overlay Engine"}),e("p",{className:"text-lg text-muted-foreground",children:"`@contractspec/lib.overlay-engine` keeps OverlaySpecs typed, signed, and auditable across tenants, roles, users, and devices."})]}),i("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(d,{package:"@contractspec/lib.overlay-engine"})]}),i("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Define + Sign"}),e(n,{language:"typescript",code:`import { defineOverlay } from '@contractspec/lib.overlay-engine/spec';
import { signOverlay } from '@contractspec/lib.overlay-engine/signer';

const overlay = defineOverlay({
  overlayId: 'acme-order-form',
  version: '1.0.0',
  appliesTo: { capability: 'billing.createOrder', tenantId: 'acme' },
  modifications: [{ type: 'hideField', field: 'internalNotes' }],
});

const signed = await signOverlay(overlay, privateKeyPem);`})]}),i("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Runtime"}),e("p",{className:"text-muted-foreground",children:"`OverlayRegistry` stores signed overlays with specificity scoring. `OverlayEngine` merges modifications and emits audit events."}),e(n,{language:"typescript",code:`const registry = new OverlayRegistry();
registry.register(signed);

const engine = new OverlayEngine({
  registry,
  audit: (event) => auditLog.write(event),
});

const result = engine.apply({
  target: { fields },
  capability: 'billing.createOrder',
  tenantId: 'acme',
});`})]}),i("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"React Hooks"}),e("p",{className:"text-muted-foreground",children:"Render overlays in React/React Native via `useOverlay`."}),e(n,{language:"typescript",code:`import { useOverlay } from '@contractspec/lib.overlay-engine/react';

const { target } = useOverlay(engine, {
  target: { fields },
  capability: 'billing.createOrder',
  tenantId: 'acme',
});`})]}),i("div",{className:"flex items-center gap-4 pt-4",children:[e(l,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),i(l,{href:"/docs/libraries/workflow-composer",className:"btn-primary",children:["Next: Workflow Composer ",e(g,{size:16})]})]})]})}export{u as LibrariesOverlayEnginePage};
