"use strict";const e=require("./css-SuMNMmEe.cjs"),l=require("./jsx-runtime-evvPGacs.cjs"),r=require("./Toggle-r0neBlcF.cjs"),b=require("react");require("./Center-7mG_M7Co.cjs");require("./aggregator-Plx04vqJ.cjs");require("react-hook-form");const g=({value:o,onChange:t,...u})=>{const i=s=>{s.hex==="transparent"&&t(e.ZERO),t(new e.Color(s.hex,s.rgb.a))};return l.jsxRuntimeExports.jsx(r.SketchPicker,{className:e.CSS.B("color-picker"),color:new e.Color(o).hex,onChange:i,presetColors:[],...u})},x="color",d=({value:o,onChange:t,className:u,size:i="medium",onVisibleChange:s,initialVisible:m,draggable:h=!0,...j})=>{const{visible:k,open:y,close:C}=r.use$1({onVisibleChange:s,initialVisible:m}),f=r.use().colors.gray.l0,c=new e.Color(o),w=r.useDraggingState(),S=b.useCallback(({items:a})=>{const[n]=r.filterByType(x,a);return n!=null&&n.key!==c.hex},[c.hex]),{startDrag:R,...E}=r.useDragAndDrop({type:"Color.Swatch",onDrop:({items:a})=>{const n=r.filterByType(x,a);return a.length>0&&(t==null||t(new e.Color(n[0].key))),n},canDrop:S}),p=l.jsxRuntimeExports.jsx(r.Button,{className:e.CSS(e.CSS.B("color-swatch"),e.CSS.size(i),c.contrast(f)>1.5&&c.a>.5&&e.CSS.M("no-border"),e.CSS.dropRegion(S(w)),u),draggable:h,onDragStart:()=>R([{type:x,key:c.hex}]),style:{backgroundColor:e.cssString(o)},variant:"text",onClick:y,size:i,tooltip:t!=null?l.jsxRuntimeExports.jsx(r.Text,{level:"small",children:"Click to change color"}):void 0,...E,...j});return t==null?p:l.jsxRuntimeExports.jsxs(r.Dialog,{close:C,visible:k,className:e.CSS.BE("color-swatch","dropdown"),keepMounted:!1,variant:"floating",children:[p,l.jsxRuntimeExports.jsx(g,{value:o,onChange:t})]})},D=Object.freeze(Object.defineProperty({__proto__:null,Color:e.Color,Picker:g,Swatch:d,ZERO:e.ZERO,cssString:e.cssString,fromHSLA:e.fromHSLA,toHex:e.toHex},Symbol.toStringTag,{value:"Module"}));exports.Swatch=d;exports.external=D;
//# sourceMappingURL=external-4pMxPo4K.cjs.map
