import{__assign as i}from"tslib";import{jsxs as o,Fragment as n,jsx as e}from"react/jsx-runtime";import c from"react";import{Check as t,X as l,ChevronUp as r,AlertTriangle as s}from"lucide-react";import a from"./OverrideTimeline.js";import{HistorySkeleton as d}from"./HistorySkeleton.js";import m from"../styles/RuleAccordion.module.css.js";var p=function(p){var h=p.type,v=p.conditions,N=p.isOpen,y=p.onToggle,u=p.showOverrideHistory,f=void 0!==u&&u,g=p.isLoadingHistory,A=void 0!==g&&g,I=p.historyError,L=p.overrideHistoryData,k=p.labelText,C=p.noConditionsText,H=void 0===C?"No conditions":C,B=null!=k?k:"apply"===h?"When to Apply":"When Not to Apply",O="apply"===h?"".concat(m.conditionBlock," ").concat(m.conditionBlockApply):"".concat(m.conditionBlock," ").concat(m.conditionBlockNotApply),T="apply"===h?m.conditionIconApply:m.conditionIconNotApply,b=c.useMemo(function(){return v?Array.isArray(v)?v:v.split(" OR ").map(function(i){return i.trim()}):[]},[v]);return o("div",i({className:O},{children:["apply"===h&&o(n,{children:[e("div",{className:m.verticalLine}),e("div",{className:m.horizontalLine})]}),"notApply"===h&&e("div",{className:m.curvedLine}),o("div",i({className:m.conditionContent},{children:[e("div",i({className:m.conditionHeader,onClick:y},{children:o("div",i({className:m.conditionIconWrapper},{children:[e("div",i({className:T},{children:e("apply"===h?t:l,{size:10,strokeWidth:3})})),e("span",i({className:m.conditionLabel},{children:B})),e("button",i({className:m.conditionToggleButton},{children:e(r,{size:16,className:N?m.chevronOpen:m.chevronClosed})}))]}))})),N&&e("div",i({className:m.conditionItems},{children:b.length>0?o("div",i({className:m.conditionItemContainer},{children:[e("div",i({className:m.conditionItemHeader},{children:e("div",i({className:m.conditionItemContent},{children:e("ol",i({className:m.conditionList},{children:b.map(function(o,n){return e("li",i({className:m.conditionListItem},{children:o}),n)})}))}))})),f?A?e(d,{}):I?o("div",i({className:m.errorMessage},{children:[e(s,{size:14}),e("span",{children:I})]})):L?e(a,{changeLog:L}):null:null]})):e("div",i({className:m.noConditions},{children:H}))})),!N&&e("div",{className:m.collapsedPadding})]}))]}))};export{p as default};
//# sourceMappingURL=RuleConditionBlock.js.map
