@e-llm-studio/instant-learning 1.3.0-alpha.296 → 1.3.0-alpha.297

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),n=require("react/jsx-runtime"),e=require("react"),t=require("../../InputDataReasoningCard.js"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=require("../../organisms/ConfigSection/ConfigSection.js"),r=require("../../organisms/ScopeSection/ScopeSection.js"),a=require("../../organisms/TextSection/TextSection.js"),d=require("../../AccordianSection.js"),s=require("../../_svg/ButtonCognitiveIcon.js"),u=require("../../_svg/EditPencilIcon.js"),c=require("lucide-react"),p=require("../../../../LearningManagement/store/useLearningTemplateStore.js"),v=require("../../hooks/useVariantEditSession.js");function f(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var g=f(e),h=function(e){var t=e.children,o=e.onAddVariant,l=e.isDisabled,r=e.showAddVariantBtn,a=void 0===r||r,d=e.showConnectorLines,s=void 0===d||d,u=g.default.Children.toArray(t);return n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start",width:"100%",minWidth:0,maxWidth:"100%",boxSizing:"border-box"}},{children:[u.map(function(i,e){var t=e===u.length-1,o=s&&(!t||a);return n.jsxs(g.default.Fragment,{children:[i,o&&n.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"var(--il-border, #e2e8f0)",marginLeft:"30px"}})]},e)}),a&&n.jsx("div",i.__assign({onClick:l?void 0:o,style:{padding:"8px 16px",border:"1px solid var(--il-border, #E2E8F0)",borderRadius:"8px",color:l?"var(--il-disabled, #94A3B8)":"var(--il-secondary-fg, #475569)",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"var(--il-surface-alt, #f8fafc)":"var(--il-surface, #ffffff)",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(f){var x,y,m,_,T,C,b,S,A,E,I,D,j,w=f.state,O=f.handlers,V=f.uiState,R=p.useLearningTemplateStore(function(i){return i.backwardCompatibility}),B=(null==V?void 0:V.highlights)||new Map,P=B.get("global_0")||{},W=e.useState({}),N=W[0],k=W[1],L=e.useState(null),z=L[0],q=L[1],M=e.useState(function(){var i,n,e;if((null==V?void 0:V.defaultTierOpen)>=0&&(null===(i=null==V?void 0:V.tierOptions)||void 0===i?void 0:i[V.defaultTierOpen]))return V.tierOptions[V.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(e=null===(n=w.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e[0];return t?t.toLowerCase().replace(/ /g,"_"):null});M[0];var F=M[1],J="rule-setup"===(null==V?void 0:V.activeEditId),H=g.default.useRef(new Map),K=v.useVariantEditSession(V,function(n){var e,t;return{ruleDescription:(null==n?void 0:n.ruleDescription)||"",instructionPrompt:null!==(t=null!==(e=null==n?void 0:n.instructionPrompt)&&void 0!==e?e:null==V?void 0:V.instructionPrompt)&&void 0!==t?t:"",whenToApplyConditions:((null==n?void 0:n.whenToApplyConditions)||[]).map(function(n){return i.__assign({},n)}),whenNotToApplyConditions:((null==n?void 0:n.whenNotToApplyConditions)||[]).map(function(n){return i.__assign({},n)})}},function(i){var n;void 0!==i.instructionPrompt&&(null===(n=null==V?void 0:V.setInstructionPrompt)||void 0===n||n.call(V,i.instructionPrompt))}),$=K.variantEdit,U=K.pendingVariantId,Z=K.handleStartVariantEdit,G=K.handleCancelVariantEdit,Q=K.patchVariantDraft,X=K.editDraftCondition,Y=K.removeDraftCondition,ii=K.addDraftCondition,ni=K.handleSaveVariantEdit,ei=e.useState(null),ti=ei[0],oi=ei[1],li=e.useState(null),ri=li[0],ai=li[1],di=e.useState(!1),si=di[0],ui=di[1],ci=g.default.useRef(null==V?void 0:V.isAiStreaming);e.useEffect(function(){ci.current&&!(null==V?void 0:V.isAiStreaming)&&si&&ui(!1),ci.current=null==V?void 0:V.isAiStreaming},[null==V?void 0:V.isAiStreaming,si]);var pi=function(){var n,e;(null==V?void 0:V.activeEditId)&&"rule-setup"!==V.activeEditId||(null===(n=null==V?void 0:V.setActiveEditId)||void 0===n||n.call(V,"rule-setup"),oi(null!==(e=w.ruleTitle)&&void 0!==e?e:""),ai(w.scopeData?i.__assign({},w.scopeData):{}))},vi=function(){var i;oi(null),ai(null),null===(i=null==V?void 0:V.setActiveEditId)||void 0===i||i.call(V,null)},fi=function(){var i,n,e=null!=ti?ti:w.ruleTitle,t=null!=ri?ri:w.scopeData,o=e!==w.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(w.scopeData);if(!o&&!l)return oi(null),ai(null),void(null===(i=null==V?void 0:V.setActiveEditId)||void 0===i||i.call(V,null));if(null==V?void 0:V.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==e?void 0:e.trim())?"with ".concat(e):"cleared"),l){var d=null==t?void 0:t.tiers,s=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(s)}var u=a.join(" and "),c=(null==V?void 0:V.ruleTitle)||"Rule Setup";V.setSendMessageInChat("__SKELETON__:".concat(r,":Update ").concat(c," ").concat(u))}ui(!0),oi(null),ai(null),null===(n=null==V?void 0:V.setActiveEditId)||void 0===n||n.call(V,null)},gi=null!==ti?null==ti?void 0:ti.trim():(w.ruleTitle||"").trim(),hi=null!=ri?ri:w.scopeData,xi=gi!==(w.ruleTitle||"").trim(),yi=JSON.stringify(hi)!==JSON.stringify(w.scopeData),mi=""===gi,_i=!xi&&!yi||mi,Ti=g.default.useRef(null==V?void 0:V.defaultVariantOpen),Ci=g.default.useRef(null==V?void 0:V.activeVariantAccordionIndex),bi=g.default.useRef(null==V?void 0:V.defaultTierOpen),Si=g.default.useRef(null===(x=w.scopeData)||void 0===x?void 0:x.tiers),Ai=g.default.useRef(w.variantsByTier);g.default.useEffect(function(){var i,n,e,t,o,l,r=null,a=!1;Ti.current!==(null==V?void 0:V.defaultVariantOpen)&&(a=!0,Ti.current=null==V?void 0:V.defaultVariantOpen),Ci.current!==(null==V?void 0:V.activeVariantAccordionIndex)&&(a=!0,Ci.current=null==V?void 0:V.activeVariantAccordionIndex),bi.current!==(null==V?void 0:V.defaultTierOpen)&&(a=!0,bi.current=null==V?void 0:V.defaultTierOpen);var d=(null===(i=w.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(Si.current)!==JSON.stringify(d)&&(a=!0,Si.current=d,d.length>0&&F(d[0].toLowerCase().replace(/ /g,"_")));var s=(null===(n=null==V?void 0:V.tierOptions)||void 0===n?void 0:n.filter(function(i){var n,e;return null===(e=null===(n=w.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||[],u=s.some(function(i){var n,e,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(e=null===(n=Ai.current)||void 0===n?void 0:n[l])||void 0===e?void 0:e.length)||0)!==((null===(o=null===(t=w.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var c=null!==(e=null==V?void 0:V.activeVariantAccordionIndex)&&void 0!==e?e:null==V?void 0:V.defaultVariantOpen;if(null==c||c<0)return q(null),void(Ai.current=w.variantsByTier);s.forEach(function(i,n){var e;if(!((null==V?void 0:V.defaultTierOpen)>=0&&n!==V.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(e=w.variantsByTier)||void 0===e?void 0:e[t])||[];o[c]&&(r="".concat(t,"-variant-").concat(c)),null!=(null==V?void 0:V.autoScrollVariantIndex)&&o[V.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(V.autoScrollVariantIndex))}}),r&&q(r)}if(null===z){var p=null!==(t=null==V?void 0:V.activeVariantAccordionIndex)&&void 0!==t?t:null==V?void 0:V.defaultVariantOpen;null!=p&&p>=0&&(null===(l=null===(o=null==V?void 0:V.tierOptions)||void 0===o?void 0:o.filter(function(i){var n,e;return null===(e=null===(n=w.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===l||l.forEach(function(i,n){var e;if(!((null==V?void 0:V.defaultTierOpen)>=0&&n!==V.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(e=w.variantsByTier)||void 0===e?void 0:e[t])||[])[p]&&q("".concat(t,"-variant-").concat(p))}}))}Ai.current=w.variantsByTier},[w.variantsByTier,null==V?void 0:V.defaultVariantOpen,null==V?void 0:V.activeVariantAccordionIndex,null===(y=w.scopeData)||void 0===y?void 0:y.tiers,null==V?void 0:V.tierOptions,null==V?void 0:V.autoScrollVariantIndex,null==V?void 0:V.defaultTierOpen]);var Ei=function(n){k(function(e){var t;return i.__assign(i.__assign({},e),((t={})[n]=!e[n],t))})},Ii=function(i){var n,e,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(n=w.fieldCitations)||void 0===n?void 0:n[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(e=w.fieldCitations)||void 0===e?void 0:e[i];return Array.isArray(d)&&d.length>0?d:null!==(t=w.citations)&&void 0!==t?t:[]},Di={marginTop:"-17px",position:"relative",zIndex:1};e.useEffect(function(){var i,n;null!=(null==V?void 0:V.autoScrollVariantIndex)&&v.hasMeaningfulText(w.ruleTitle)&&(null===(n=null===(i=null==V?void 0:V.tierOptions)||void 0===i?void 0:i.filter(function(i){var n,e;return null===(e=null===(n=w.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===n||n.forEach(function(i){var n=i.toLowerCase().replace(/ /g,"_"),e="".concat(n,"-variant-").concat(V.autoScrollVariantIndex),t=H.current.get(e);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==V?void 0:V.scrollTrigger,w.ruleTitle]),console.log("CreateRule state:",w),console.log("CreateRule uiState:",V);var ji=!!(null==V?void 0:V.activeEditId),wi=J&&null!==ti?ti:w.ruleTitle,Oi=ji&&"rule-setup"!==(null==V?void 0:V.activeEditId);return n.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[n.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:n.jsx(d.default,i.__assign({title:{type:"other",label:(null==V?void 0:V.setupLabel)||"Rule Setup"},actionButtons:R?function(e,t){if(J)return null;var o=!!(null==V?void 0:V.activeEditId)&&"rule-setup"!==V.activeEditId;return n.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==V?void 0:V.setPendingEditId)&&V.setPendingEditId(V.activeEditId||null):(pi(),(null==V?void 0:V.setPendingEditId)&&V.setPendingEditId(null),e||t())},disabled:si,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid var(--il-border, #e5e7eb)",borderRadius:"8px",cursor:si?"not-allowed":"pointer",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-muted, #64748B)",opacity:si?.5:1}},{children:si?"Validating...":R?n.jsx(c.Pencil,{size:14}):n.jsx(u.EditPencilIcon,{size:12})}))}))}:function(e,t){if(J){var o={display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500};return n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),fi()},disabled:_i||si,style:i.__assign(i.__assign({},o),{backgroundColor:si?"var(--il-primary-subtle, #f5f3ff)":"var(--il-surface, #ffffff)",cursor:_i||si?"not-allowed":"pointer",opacity:_i?.5:1,border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)"})},{children:si?"Validating...":"Save"})),!si&&n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),vi()},style:i.__assign(i.__assign({},o),{backgroundColor:"var(--il-surface, #ffffff)",cursor:"pointer",border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)"})},{children:"Cancel"}))]}))}var l=(null==V?void 0:V.hideSetupEdit)&&"Edit"===(null==V?void 0:V.usedFor);return n.jsx(n.Fragment,{children:!l&&n.jsx("button",i.__assign({title:Oi?"Save active edits first":mi?"Add":"Edit",onClick:function(i){i.stopPropagation(),Oi?(null==V?void 0:V.setPendingEditId)&&V.setPendingEditId(V.activeEditId||null):(pi(),(null==V?void 0:V.setPendingEditId)&&V.setPendingEditId(null),e||t())},disabled:si,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px ",border:"1px solid var(--il-border, #CBD5E1)",borderRadius:"6px",backgroundColor:"var(--il-surface, #ffffff)",color:si&&(null==V?void 0:V.isAiStreaming)?"var(--il-primary, #2563EB)":"var(--il-muted, #64748B)",fontSize:"13px",fontWeight:500,cursor:si?"not-allowed":"pointer",opacity:si?.5:1}},{children:si?"Validating...":n.jsxs(n.Fragment,{children:[n.jsx(u.EditPencilIcon,{size:12}),mi?"Add":"Edit"]})}))})},footerData:{ruleTitle:w.ruleTitle,stations:[w.scopeData.station],tiers:null===(m=w.scopeData)||void 0===m?void 0:m.tiers},defaultOpen:"Create"===(null==V?void 0:V.usedFor),readOnly:"Create"!==(null==V?void 0:V.usedFor),isAiStreaming:null==V?void 0:V.isAiStreaming,editFlow:R&&"Edit"===(null==V?void 0:V.usedFor),showAccentBorder:mi},{children:n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[R&&si&&(null==V?void 0:V.isAiStreaming)&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"var(--il-foreground, #141414)",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n.jsx(c.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),R?n.jsxs(n.Fragment,{children:[n.jsx(a.TextSection,i.__assign({id:"rule-title",title:V.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:wi,onChange:function(i){return J?oi(i):O.setRuleTitle(i)},readOnly:(null==V?void 0:V.isAiStreaming)||!J,isOpen:N.ruleTitle,onToggle:function(){return Ei("ruleTitle")},isHighlighted:P.ruleTitle||!1,showCognitiveIcon:w.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(_=V.validationErrors)||void 0===_?void 0:_.ruleTitle},V)),w.citation.ruleTitle&&n.jsx("div",i.__assign({style:Di},{children:n.jsx(t.InputDataReasoningCard,{isVisible:N.ruleTitle,citation:w.citation.ruleTitle,citations:Ii("ruleTitle"),fieldName:"Rule Title",fieldValue:w.ruleTitle})}))]}):n.jsxs(n.Fragment,{children:[n.jsx(a.TextSection,i.__assign({id:"rule-title",title:V.ruleTitle||"Rule Title",subtitle:null==V?void 0:V.ruleTitleInformation,rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:wi,onChange:function(i){return J?oi(i):O.setRuleTitle(i)},readOnly:(null==V?void 0:V.isAiStreaming)||!J,isOpen:N.ruleTitle,onToggle:function(){return Ei("ruleTitle")},isHighlighted:P.ruleTitle||!1,showCognitiveIcon:w.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(T=V.validationErrors)||void 0===T?void 0:T.ruleTitle},V)),w.citation.ruleTitle&&n.jsx("div",i.__assign({style:Di},{children:n.jsx(t.InputDataReasoningCard,{isVisible:N.ruleTitle,citation:w.citation.ruleTitle,citations:Ii("ruleTitle"),fieldName:"Rule Title",fieldValue:w.ruleTitle})}))]}),(null===(C=null==V?void 0:V.tierOptions)||void 0===C?void 0:C.length)>1&&n.jsx(r.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:J&&null!==ri?ri:w.scopeData,onScopeChange:function(n,e){J?ai(function(t){var o;return i.__assign(i.__assign({},null!=t?t:w.scopeData),((o={})[n]=e,o))}):O.onScopeChange(n,e)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:P,isOpen:N.scopeData,onToggle:function(){return Ei("scopeData")},showCognitiveIcon:w.citation.scopeData,cognitiveIcon:n.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(b=V.validationErrors)||void 0===b?void 0:b.station)||(null===(S=V.validationErrors)||void 0===S?void 0:S.tiers),stationErrorMessage:null===(A=V.validationErrors)||void 0===A?void 0:A.station,tierErrorMessage:null===(E=V.validationErrors)||void 0===E?void 0:E.tiers,readOnly:(null==V?void 0:V.isAiStreaming)||!J},V)),w.citation.scopeData&&n.jsx("div",i.__assign({style:Di},{children:n.jsx(t.InputDataReasoningCard,{isVisible:N.scopeData,citation:w.citation.scopeData,citations:Ii("scopeData"),fieldName:"Scope",fieldValue:null===(D=null===(I=w.scopeData)||void 0===I?void 0:I.tiers)||void 0===D?void 0:D.join(", ")})})),J?n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[R&&n.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n.jsx("button",i.__assign({onClick:vi,style:{background:"none",border:"none",color:"var(--il-muted, #64748B)",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),n.jsxs("button",i.__assign({onClick:fi,disabled:_i,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"var(--il-primary, #2563eb)",color:"var(--il-primary-fg, #ffffff)",fontSize:"14px",fontWeight:"500",cursor:_i?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:_i?.5:1}},{children:[n.jsx(c.Check,{size:18,strokeWidth:2.5,color:"var(--il-primary-fg, #ffffff)"}),"Save Changes"]}))]})),"rule-setup"===(null==V?void 0:V.pendingEditId)&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n.jsx(c.AlertTriangle,{size:14,style:{color:"var(--il-warning, #C2410C)"}}),n.jsx("div",i.__assign({style:{color:"var(--il-warning, #C2410C)",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),(!(null==V?void 0:V.tierOptions)||0===V.tierOptions.length)&&n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",padding:"32px 16px",marginTop:"8px",backgroundColor:"var(--il-surface-alt, #f8fafc)",border:"1px dashed var(--il-border, #E2E8F0)",borderRadius:"12px",color:"var(--il-disabled, #94A3B8)"}},{children:[n.jsx(c.AlertTriangle,{size:20,style:{color:"var(--il-disabled, #94A3B8)"}}),n.jsx("span",i.__assign({style:{fontSize:"13px",fontWeight:500,color:"var(--il-muted, #64748B)"}},{children:"No tiers found"}))]})),null===(j=null==V?void 0:V.tierOptions)||void 0===j?void 0:j.map(function(r,s){var p,f,x,y,m,_,T,C=r.toLowerCase().replace(/ /g,"_"),b=(null===(p=w.variantsByTier)||void 0===p?void 0:p[C])||[],S=null===(x=null===(f=w.scopeData)||void 0===f?void 0:f.tiers)||void 0===x?void 0:x.includes(r),A=b.length,E=!1;if(1===A){var I=b[0],D=!(null===(y=null==I?void 0:I.ruleDescription)||void 0===y?void 0:y.trim()),j=(null===(m=null==I?void 0:I.whenToApplyConditions)||void 0===m?void 0:m.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,P=(null===(_=null==I?void 0:I.whenNotToApplyConditions)||void 0===_?void 0:_.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!D||j||P||(E=!0)}var W=E?void 0:"".concat(A," ").concat(1===A?"variant":"variants"," configured for this tier"),k=n.jsx(h,i.__assign({onAddVariant:function(){var i;return null===(i=O.addNewVariant)||void 0===i?void 0:i.call(O,C)},isDisabled:!S||(null==V?void 0:V.isAiStreaming),showAddVariantBtn:R&&"Edit"!==(null==V?void 0:V.usedFor)},{children:b.map(function(r,s){var p,f,g,h,x,y,m,_,T,b,A,E=r.variantType||"default",I="".concat(C,"-variant-").concat(s),D=!0===r.is_variant,j="default"===E||"default_variant"===E,P="".concat(C,"_").concat(s),W=B.get(P)||{},k=(null===(f=null===(p=V.separationItemsByTier)||void 0===p?void 0:p[C])||void 0===f?void 0:f.get(s))||[],L=(null===(h=null===(g=V.togglesByTier)||void 0===g?void 0:g[C])||void 0===h?void 0:h.get(s))||[],M=null===(x=null==V?void 0:V.activeEditId)||void 0===x?void 0:x.startsWith("condition-wta-".concat(C,"-").concat(s)),F=null===(y=null==V?void 0:V.activeEditId)||void 0===y?void 0:y.startsWith("condition-wnta-".concat(C,"-").concat(s)),J=!S||r.isReadOnly||(null==V?void 0:V.isAiStreaming),K=j?function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"}(E):"".concat((null==V?void 0:V.variantPillLabel)||"Variant"," ").concat(s+1),ei="variant-".concat(C,"-").concat(s),ti=!R&&(null==$?void 0:$.id)===ei,oi=U===ei,li=ti?$.draft:null,ri=J||oi,ai=li?li.ruleDescription:r.ruleDescription||"",di=li?li.instructionPrompt:null!==(m=r.instructionPrompt)&&void 0!==m?m:V.instructionPrompt,si=li?li.whenToApplyConditions:r.whenToApplyConditions||[],ui=li?li.whenNotToApplyConditions:r.whenNotToApplyConditions||[],ci=!li||!v.hasMeaningfulText(li.ruleDescription)||!li.whenToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)});return n.jsx("div",i.__assign({ref:function(i){i?H.current.set(I,i):H.current.delete(I)},style:{width:"100%",opacity:S?1:.7},"data-edit-id":R?void 0:ei},{children:n.jsx(d.default,i.__assign({title:{type:j?"default":"variant",label:K,number:s+1,isNewVariant:D,isDefault:r.isDefault,isModified:r.isModified},defaultOpen:!0,expanded:z===I,onToggle:function(){var i,n=z===I;q(n?null:I),null===(i=null==V?void 0:V.setActiveVariantAccordionIndex)||void 0===i||i.call(V,n?null:s)},variant:"rule-behavior",footerData:{ruleTitle:E,description:r.ruleDescription||""},readOnly:J,actionButtons:R?void 0:function(e,t){if(R)return null;if(J&&!ti&&!oi)return null;if(ti||oi)return n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),ni()},disabled:ci||oi,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10.5px",borderRadius:"6px",border:"1px solid var(--il-primary, #D9D6FE)",backgroundColor:oi?"var(--il-primary-subtle, #f5f3ff)":"var(--il-surface, #ffffff)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500,cursor:ci||oi?"not-allowed":"pointer",opacity:ci?.5:1}},{children:oi?"Validating...":"Save"})),!oi&&n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),G()},style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10.5px",borderRadius:"6px",border:"1px solid var(--il-primary, #D9D6FE)",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500,cursor:"pointer"}},{children:"Cancel"}))]}));var o=!(v.hasMeaningfulText(r.ruleDescription)||r.whenToApplyConditions&&r.whenToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)})||r.whenNotToApplyConditions&&r.whenNotToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)}));return n.jsxs("button",i.__assign({title:ri?"Editing unavailable":o?"Add":"Edit",onClick:function(i){i.stopPropagation(),Z(r,C,s,K),e||t()},disabled:ri,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"1px solid var(--il-border, #CBD5E1)",borderRadius:"6px",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-muted, #64748B)",fontSize:"13px",fontWeight:500,cursor:ri?"not-allowed":"pointer",opacity:ri?.5:1,gap:"6px"}},{children:[n.jsx(u.EditPencilIcon,{size:12})," ",o?"Add":"Edit"]}))},isAiStreaming:null==V?void 0:V.isAiStreaming,alwaysShowActions:!R,showAccentBorder:!mi},{children:n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n.jsx(a.TextSection,i.__assign({id:"rule-description-".concat(C,"-").concat(s),title:V.ruleDescriptionTitle||"Rule Description",subtitle:null==V?void 0:V.ruleDescriptionInformation,rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:R?J||ji&&(null==V?void 0:V.activeEditId)!=="rule-description-".concat(C,"-").concat(s):J||!ti,value:ai,onChange:function(i){return R?O.setRuleDescription(C,s,i):Q({ruleDescription:i})},isOpen:N["ruleDescription-".concat(C)],onToggle:function(){return Ei("ruleDescription-".concat(C))},isHighlighted:W.ruleDescription||!1,showCognitiveIcon:null===(_=w.citation)||void 0===_?void 0:_["ruleDescription_".concat(C)],tooltipDescription:"Why this Description?",errorMessage:null===(T=V.validationErrors)||void 0===T?void 0:T["ruleDescription-".concat(C,"-").concat(s)],enableInlineEdit:R,setSendMessageInChat:null==V?void 0:V.setSendMessageInChat,isAiStreaming:null==V?void 0:V.isAiStreaming,fieldName:"Rule Description"},V)),(null===(b=w.citation)||void 0===b?void 0:b["ruleDescription_".concat(C)])&&n.jsx("div",i.__assign({style:Di},{children:n.jsx(t.InputDataReasoningCard,{isVisible:N["ruleDescription-".concat(C)],citation:w.citation["ruleDescription_".concat(C)],citations:Ii("ruleDescription_".concat(C,"_").concat(s)),fieldName:"Rule Description",fieldValue:r.ruleDescription})})),n.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(C,"-").concat(s),idPrefix:"condition-wta",title:V.whenToApplyTitle||"When to apply",subtitle:null==V?void 0:V.wtaInformation,required:!0,dividerRequired:!0,readOnly:R?J||ji&&!M:J,hideEditControls:!R,parentEditing:ti,conditions:si,onAdd:function(){return R?O.addWhenToApply(C,s):ii("whenToApplyConditions")},onRemove:function(i,n,e){return R?O.removeWhenToApply(i,n,e):Y("whenToApplyConditions",e)},onEdit:function(i,n,e,t){return R?O.editWhenToApply(i,n,e,t):X("whenToApplyConditions",e,t)},index:s,tierKey:C,isHighlighted:W.wta||!1,highlightedIds:null==V?void 0:V.highlightedIds,tooltipDescription:"Why this Condition?",citations:Ii("whenToApply_".concat(C,"_").concat(s)),bordered:!0,addLabel:(null==V?void 0:V.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:V.isAiStreaming,errorMessage:(null===(A=V.validationErrors)||void 0===A?void 0:A["whenToApply-".concat(C,"-").concat(s)])||(null==V?void 0:V.conflictReason)},V)),n.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(C,"-").concat(s),idPrefix:"condition-wnta",title:V.whenNotToApplyTitle||"When NOT to apply",subtitle:null==V?void 0:V.wntaInformation,required:!1,dividerRequired:!0,readOnly:R?J||ji&&!F:J,hideEditControls:!R,parentEditing:ti,conditions:ui,onAdd:function(){return R?O.addWhenNotToApply(C,s):ii("whenNotToApplyConditions")},onRemove:function(i,n,e){return R?O.removeWhenNotToApply(i,n,e):Y("whenNotToApplyConditions",e)},onEdit:function(i,n,e,t){return R?O.editWhenNotToApply(i,n,e,t):X("whenNotToApplyConditions",e,t)},index:s,tierKey:C,isHighlighted:W.wnta||!1,highlightedIds:null==V?void 0:V.highlightedIds,tooltipDescription:"Why this Condition?",citations:Ii("whenNotToApply_".concat(C,"_").concat(s)),bordered:!0,addLabel:(null==V?void 0:V.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:V.isAiStreaming},V)),(null==V?void 0:V.LazyPromptEditor)&&n.jsx(e.Suspense,i.__assign({fallback:n.jsx("div",i.__assign({style:{padding:"12px",fontSize:"13px",color:"var(--il-muted, #64748B)"}},{children:"Loading editor..."}))},{children:n.jsx(V.LazyPromptEditor,{id:"instruction-prompt-".concat(C,"-").concat(s),title:V.instructionPromptTitle,description:null==V?void 0:V.promptDescriptionInformation,value:di,onChange:function(i){var n;return R?null===(n=V.setInstructionPrompt)||void 0===n?void 0:n.call(V,i):Q({instructionPrompt:i})},readOnly:R?J:J||!ti,hideEditControls:!R,parentEditing:ti,enableViewToggle:null==V?void 0:V.instructionPromptViewToggle,isAiStreaming:null==V?void 0:V.isAiStreaming,tierKey:C,variantIndex:s,uiState:V})})),(null==V?void 0:V.showConfiguration)&&n.jsx(l.ConfigSection,i.__assign({id:"config-".concat(C,"-").concat(s),title:V.configTitle||"Configuration",required:!1,highlights:W,bordered:!0,readOnly:J||ji&&(null==V?void 0:V.activeEditId)!=="config-".concat(C,"-").concat(s),onConfigChange:function(i,n){return O.onConfigChange(C,s,i,n)},separationItems:k,toggles:L,index:s},V)),!R&&ti&&(null==V?void 0:V.pendingEditId)===ei&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx(c.AlertTriangle,{size:14,style:{color:"var(--il-warning, #C2410C)"}}),n.jsx("div",i.__assign({style:{color:"var(--il-warning, #C2410C)",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))}),I)}),"".concat(C,"-variant-").concat(s))})}));return 1===(null===(T=null==V?void 0:V.tierOptions)||void 0===T?void 0:T.length)?n.jsx(g.default.Fragment,{children:k},"tier-".concat(s)):n.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:r},subtitle:W,defaultOpen:!0,footerData:{description:"Variants for ".concat(r)}},{children:k}),"tier-".concat(s))})]}))},exports.VariantListWrapper=h;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("tslib"),n=require("react/jsx-runtime"),e=require("react"),t=require("../../InputDataReasoningCard.js"),o=require("../../organisms/ConditionSection/ConditionSection.js"),l=require("../../organisms/ConfigSection/ConfigSection.js"),r=require("../../organisms/ScopeSection/ScopeSection.js"),a=require("../../organisms/TextSection/TextSection.js"),d=require("../../AccordianSection.js"),s=require("../../_svg/ButtonCognitiveIcon.js"),u=require("../../_svg/EditPencilIcon.js"),c=require("lucide-react"),p=require("../../../../LearningManagement/store/useLearningTemplateStore.js"),v=require("../../hooks/useVariantEditSession.js");function g(i){return i&&"object"==typeof i&&"default"in i?i:{default:i}}var f=g(e),h=function(n){void 0===n&&(n=[]);var e=[],t=new Map;return n.forEach(function(n){var o,l,r=(l=null==n?void 0:n.text,String(l||"").replace(/<conflicting_text>[\s\S]*?<\/conflicting_text>/g,"").replace(/<decision_strength>[\s\S]*?<\/decision_strength>/g,"").replace(/<conflicting_reasoning>[\s\S]*?<\/conflicting_reasoning>/g,"").replace(/<conflicting_gap>[\s\S]*?<\/conflicting_gap>/g,"").replace(/<\/?conflicting>/g,"").replace(/\s+/g," ").trim().toLowerCase());if(r){var a=t.get(r);if(void 0===a)return t.set(r,e.length),void e.push(n);(null==n?void 0:n.conflict)&&!(null===(o=e[a])||void 0===o?void 0:o.conflict)&&(e[a]=i.__assign(i.__assign({},e[a]),{conflict:n.conflict}))}else e.push(n)}),e},x=function(e){var t=e.children,o=e.onAddVariant,l=e.isDisabled,r=e.showAddVariantBtn,a=void 0===r||r,d=e.showConnectorLines,s=void 0===d||d,u=f.default.Children.toArray(t);return n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start",width:"100%",minWidth:0,maxWidth:"100%",boxSizing:"border-box"}},{children:[u.map(function(i,e){var t=e===u.length-1,o=s&&(!t||a);return n.jsxs(f.default.Fragment,{children:[i,o&&n.jsx("div",{style:{width:"2px",height:"20px",backgroundColor:"var(--il-border, #e2e8f0)",marginLeft:"30px"}})]},e)}),a&&n.jsx("div",i.__assign({onClick:l?void 0:o,style:{padding:"8px 16px",border:"1px solid var(--il-border, #E2E8F0)",borderRadius:"8px",color:l?"var(--il-disabled, #94A3B8)":"var(--il-secondary-fg, #475569)",fontSize:"14px",fontWeight:"500",cursor:l?"not-allowed":"pointer",backgroundColor:l?"var(--il-surface-alt, #f8fafc)":"var(--il-surface, #ffffff)",opacity:l?.7:1,userSelect:"none",transition:"all 0.2s ease"}},{children:"Add Variant"}))]}))};exports.CreateRule=function(g){var y,_,m,T,C,S,b,A,E,I,D,j,w,O=g.state,V=g.handlers,R=g.uiState,B=p.useLearningTemplateStore(function(i){return i.backwardCompatibility}),P=(null==R?void 0:R.highlights)||new Map,W=P.get("global_0")||{},N=e.useState({}),k=N[0],L=N[1],z=e.useState(null),M=z[0],q=z[1],F=e.useState(function(){var i,n,e;if((null==R?void 0:R.defaultTierOpen)>=0&&(null===(i=null==R?void 0:R.tierOptions)||void 0===i?void 0:i[R.defaultTierOpen]))return R.tierOptions[R.defaultTierOpen].toLowerCase().replace(/ /g,"_");var t=null===(e=null===(n=O.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e[0];return t?t.toLowerCase().replace(/ /g,"_"):null});F[0];var J=F[1],H="rule-setup"===(null==R?void 0:R.activeEditId),K=f.default.useRef(new Map),$=v.useVariantEditSession(R,function(n){var e,t;return{ruleDescription:(null==n?void 0:n.ruleDescription)||"",instructionPrompt:null!==(t=null!==(e=null==n?void 0:n.instructionPrompt)&&void 0!==e?e:null==R?void 0:R.instructionPrompt)&&void 0!==t?t:"",whenToApplyConditions:((null==n?void 0:n.whenToApplyConditions)||[]).map(function(n){return i.__assign({},n)}),whenNotToApplyConditions:((null==n?void 0:n.whenNotToApplyConditions)||[]).map(function(n){return i.__assign({},n)})}},function(i){var n;void 0!==i.instructionPrompt&&(null===(n=null==R?void 0:R.setInstructionPrompt)||void 0===n||n.call(R,i.instructionPrompt))}),U=$.variantEdit,Z=$.pendingVariantId,G=$.handleStartVariantEdit,Q=$.handleCancelVariantEdit,X=$.patchVariantDraft,Y=$.editDraftCondition,ii=$.removeDraftCondition,ni=$.addDraftCondition,ei=$.handleSaveVariantEdit,ti=e.useState(null),oi=ti[0],li=ti[1],ri=e.useState(null),ai=ri[0],di=ri[1],si=e.useState(!1),ui=si[0],ci=si[1],pi=f.default.useRef(null==R?void 0:R.isAiStreaming);e.useEffect(function(){pi.current&&!(null==R?void 0:R.isAiStreaming)&&ui&&ci(!1),pi.current=null==R?void 0:R.isAiStreaming},[null==R?void 0:R.isAiStreaming,ui]);var vi=function(){var n,e;(null==R?void 0:R.activeEditId)&&"rule-setup"!==R.activeEditId||(null===(n=null==R?void 0:R.setActiveEditId)||void 0===n||n.call(R,"rule-setup"),li(null!==(e=O.ruleTitle)&&void 0!==e?e:""),di(O.scopeData?i.__assign({},O.scopeData):{}))},gi=function(){var i;li(null),di(null),null===(i=null==R?void 0:R.setActiveEditId)||void 0===i||i.call(R,null)},fi=function(){var i,n,e=null!=oi?oi:O.ruleTitle,t=null!=ai?ai:O.scopeData,o=e!==O.ruleTitle,l=JSON.stringify(t)!==JSON.stringify(O.scopeData);if(!o&&!l)return li(null),di(null),void(null===(i=null==R?void 0:R.setActiveEditId)||void 0===i||i.call(R,null));if(null==R?void 0:R.setSendMessageInChat){var r="sk-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),a=[];if(o&&a.push((null==e?void 0:e.trim())?"with ".concat(e):"cleared"),l){var d=null==t?void 0:t.tiers,s=d&&d.length>0?"tiers: ".concat(d.join(", ")):"No Tier Selected";a.push(s)}var u=a.join(" and "),c=(null==R?void 0:R.ruleTitle)||"Rule Setup";R.setSendMessageInChat("__SKELETON__:".concat(r,":Update ").concat(c," ").concat(u))}ci(!0),li(null),di(null),null===(n=null==R?void 0:R.setActiveEditId)||void 0===n||n.call(R,null)},hi=null!==oi?null==oi?void 0:oi.trim():(O.ruleTitle||"").trim(),xi=null!=ai?ai:O.scopeData,yi=hi!==(O.ruleTitle||"").trim(),_i=JSON.stringify(xi)!==JSON.stringify(O.scopeData),mi=""===hi,Ti=!yi&&!_i||mi,Ci=f.default.useRef(null==R?void 0:R.defaultVariantOpen),Si=f.default.useRef(null==R?void 0:R.activeVariantAccordionIndex),bi=f.default.useRef(null==R?void 0:R.defaultTierOpen),Ai=f.default.useRef(null===(y=O.scopeData)||void 0===y?void 0:y.tiers),Ei=f.default.useRef(O.variantsByTier);f.default.useEffect(function(){var i,n,e,t,o,l,r=null,a=!1;Ci.current!==(null==R?void 0:R.defaultVariantOpen)&&(a=!0,Ci.current=null==R?void 0:R.defaultVariantOpen),Si.current!==(null==R?void 0:R.activeVariantAccordionIndex)&&(a=!0,Si.current=null==R?void 0:R.activeVariantAccordionIndex),bi.current!==(null==R?void 0:R.defaultTierOpen)&&(a=!0,bi.current=null==R?void 0:R.defaultTierOpen);var d=(null===(i=O.scopeData)||void 0===i?void 0:i.tiers)||[];JSON.stringify(Ai.current)!==JSON.stringify(d)&&(a=!0,Ai.current=d,d.length>0&&J(d[0].toLowerCase().replace(/ /g,"_")));var s=(null===(n=null==R?void 0:R.tierOptions)||void 0===n?void 0:n.filter(function(i){var n,e;return null===(e=null===(n=O.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||[],u=s.some(function(i){var n,e,t,o,l=i.toLowerCase().replace(/ /g,"_");return((null===(e=null===(n=Ei.current)||void 0===n?void 0:n[l])||void 0===e?void 0:e.length)||0)!==((null===(o=null===(t=O.variantsByTier)||void 0===t?void 0:t[l])||void 0===o?void 0:o.length)||0)});if(u&&(a=!0),a){var c=null!==(e=null==R?void 0:R.activeVariantAccordionIndex)&&void 0!==e?e:null==R?void 0:R.defaultVariantOpen;if(null==c||c<0)return q(null),void(Ei.current=O.variantsByTier);s.forEach(function(i,n){var e;if(!((null==R?void 0:R.defaultTierOpen)>=0&&n!==R.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_"),o=(null===(e=O.variantsByTier)||void 0===e?void 0:e[t])||[];o[c]&&(r="".concat(t,"-variant-").concat(c)),null!=(null==R?void 0:R.autoScrollVariantIndex)&&o[R.autoScrollVariantIndex]&&(r="".concat(t,"-variant-").concat(R.autoScrollVariantIndex))}}),r&&q(r)}if(null===M){var p=null!==(t=null==R?void 0:R.activeVariantAccordionIndex)&&void 0!==t?t:null==R?void 0:R.defaultVariantOpen;null!=p&&p>=0&&(null===(l=null===(o=null==R?void 0:R.tierOptions)||void 0===o?void 0:o.filter(function(i){var n,e;return null===(e=null===(n=O.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===l||l.forEach(function(i,n){var e;if(!((null==R?void 0:R.defaultTierOpen)>=0&&n!==R.defaultTierOpen)){var t=i.toLowerCase().replace(/ /g,"_");((null===(e=O.variantsByTier)||void 0===e?void 0:e[t])||[])[p]&&q("".concat(t,"-variant-").concat(p))}}))}Ei.current=O.variantsByTier},[O.variantsByTier,null==R?void 0:R.defaultVariantOpen,null==R?void 0:R.activeVariantAccordionIndex,null===(_=O.scopeData)||void 0===_?void 0:_.tiers,null==R?void 0:R.tierOptions,null==R?void 0:R.autoScrollVariantIndex,null==R?void 0:R.defaultTierOpen]);var Ii=function(n){L(function(e){var t;return i.__assign(i.__assign({},e),((t={})[n]=!e[n],t))})},Di=function(i){var n,e,t,o=i.split("_"),l=o[o.length-1],r=/^\d+$/.test(l)?o.slice(0,-1).join("_"):i,a=null===(n=O.fieldCitations)||void 0===n?void 0:n[r];if(Array.isArray(a)&&a.length>0)return a;var d=null===(e=O.fieldCitations)||void 0===e?void 0:e[i];return Array.isArray(d)&&d.length>0?d:null!==(t=O.citations)&&void 0!==t?t:[]},ji={marginTop:"-17px",position:"relative",zIndex:1};e.useEffect(function(){var i,n;null!=(null==R?void 0:R.autoScrollVariantIndex)&&v.hasMeaningfulText(O.ruleTitle)&&(null===(n=null===(i=null==R?void 0:R.tierOptions)||void 0===i?void 0:i.filter(function(i){var n,e;return null===(e=null===(n=O.scopeData)||void 0===n?void 0:n.tiers)||void 0===e?void 0:e.includes(i)}))||void 0===n||n.forEach(function(i){var n=i.toLowerCase().replace(/ /g,"_"),e="".concat(n,"-variant-").concat(R.autoScrollVariantIndex),t=K.current.get(e);t&&requestAnimationFrame(function(){setTimeout(function(){t.scrollIntoView({behavior:"smooth",block:"center"})},300)})}))},[null==R?void 0:R.scrollTrigger,O.ruleTitle]),console.log("CreateRule state:",O),console.log("CreateRule uiState:",R);var wi=!!(null==R?void 0:R.activeEditId),Oi=H&&null!==oi?oi:O.ruleTitle,Vi=wi&&"rule-setup"!==(null==R?void 0:R.activeEditId);return n.jsxs("div",i.__assign({className:"traffic-manager-template"},{children:[n.jsx("div",i.__assign({"data-edit-id":"rule-setup"},{children:n.jsx(d.default,i.__assign({title:{type:"other",label:(null==R?void 0:R.setupLabel)||"Rule Setup"},actionButtons:B?function(e,t){if(H)return null;var o=!!(null==R?void 0:R.activeEditId)&&"rule-setup"!==R.activeEditId;return n.jsx("div",i.__assign({style:{position:"relative",display:"flex",flexDirection:"column"}},{children:n.jsx("button",i.__assign({title:o?"Save active edits first":"Edit",onClick:function(i){i.stopPropagation(),o?(null==R?void 0:R.setPendingEditId)&&R.setPendingEditId(R.activeEditId||null):(vi(),(null==R?void 0:R.setPendingEditId)&&R.setPendingEditId(null),e||t())},disabled:ui,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"6px 8px",border:"1px solid var(--il-border, #e5e7eb)",borderRadius:"8px",cursor:ui?"not-allowed":"pointer",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-muted, #64748B)",opacity:ui?.5:1}},{children:ui?"Validating...":B?n.jsx(c.Pencil,{size:14}):n.jsx(u.EditPencilIcon,{size:12})}))}))}:function(e,t){if(H){var o={display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderRadius:"6px",border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500};return n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),fi()},disabled:Ti||ui,style:i.__assign(i.__assign({},o),{backgroundColor:ui?"var(--il-primary-subtle, #f5f3ff)":"var(--il-surface, #ffffff)",cursor:Ti||ui?"not-allowed":"pointer",opacity:Ti?.5:1,border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)"})},{children:ui?"Validating...":"Save"})),!ui&&n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),gi()},style:i.__assign(i.__assign({},o),{backgroundColor:"var(--il-surface, #ffffff)",cursor:"pointer",border:"1px solid var(--il-border, #CBD5E1)",color:"var(--il-primary, #2563EB)"})},{children:"Cancel"}))]}))}var l=(null==R?void 0:R.hideSetupEdit)&&"Edit"===(null==R?void 0:R.usedFor);return n.jsx(n.Fragment,{children:!l&&n.jsx("button",i.__assign({title:Vi?"Save active edits first":mi?"Add":"Edit",onClick:function(i){i.stopPropagation(),Vi?(null==R?void 0:R.setPendingEditId)&&R.setPendingEditId(R.activeEditId||null):(vi(),(null==R?void 0:R.setPendingEditId)&&R.setPendingEditId(null),e||t())},disabled:ui,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px ",border:"1px solid var(--il-border, #CBD5E1)",borderRadius:"6px",backgroundColor:"var(--il-surface, #ffffff)",color:ui&&(null==R?void 0:R.isAiStreaming)?"var(--il-primary, #2563EB)":"var(--il-muted, #64748B)",fontSize:"13px",fontWeight:500,cursor:ui?"not-allowed":"pointer",opacity:ui?.5:1}},{children:ui?"Validating...":n.jsxs(n.Fragment,{children:[n.jsx(u.EditPencilIcon,{size:12}),mi?"Add":"Edit"]})}))})},footerData:{ruleTitle:O.ruleTitle,stations:[O.scopeData.station],tiers:null===(m=O.scopeData)||void 0===m?void 0:m.tiers},defaultOpen:"Create"===(null==R?void 0:R.usedFor),readOnly:"Create"!==(null==R?void 0:R.usedFor),isAiStreaming:null==R?void 0:R.isAiStreaming,editFlow:B&&"Edit"===(null==R?void 0:R.usedFor),showAccentBorder:mi},{children:n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[B&&ui&&(null==R?void 0:R.isAiStreaming)&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",color:"var(--il-foreground, #141414)",fontSize:"13px",fontWeight:500,fontStyle:"italic",marginBottom:"8px",paddingLeft:"4px"}},{children:[n.jsx(c.Loader2Icon,{size:16,style:{marginRight:8,animation:"spin 1s linear infinite"}},"loader"),"Checking the correctness of your Rule Setup..."]})),B?n.jsxs(n.Fragment,{children:[n.jsx(a.TextSection,i.__assign({id:"rule-title",title:R.ruleTitle||"Rule Title",rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:Oi,onChange:function(i){return H?li(i):V.setRuleTitle(i)},readOnly:(null==R?void 0:R.isAiStreaming)||!H,isOpen:k.ruleTitle,onToggle:function(){return Ii("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:O.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(T=R.validationErrors)||void 0===T?void 0:T.ruleTitle},R)),O.citation.ruleTitle&&n.jsx("div",i.__assign({style:ji},{children:n.jsx(t.InputDataReasoningCard,{isVisible:k.ruleTitle,citation:O.citation.ruleTitle,citations:Di("ruleTitle"),fieldName:"Rule Title",fieldValue:O.ruleTitle})}))]}):n.jsxs(n.Fragment,{children:[n.jsx(a.TextSection,i.__assign({id:"rule-title",title:R.ruleTitle||"Rule Title",subtitle:null==R?void 0:R.ruleTitleInformation,rows:1,placeholder:"Enter a short, descriptive title for the learning",required:!0,value:Oi,onChange:function(i){return H?li(i):V.setRuleTitle(i)},readOnly:(null==R?void 0:R.isAiStreaming)||!H,isOpen:k.ruleTitle,onToggle:function(){return Ii("ruleTitle")},isHighlighted:W.ruleTitle||!1,showCognitiveIcon:O.citation.ruleTitle,tooltipDescription:"Why this Title?",errorMessage:null===(C=R.validationErrors)||void 0===C?void 0:C.ruleTitle},R)),O.citation.ruleTitle&&n.jsx("div",i.__assign({style:ji},{children:n.jsx(t.InputDataReasoningCard,{isVisible:k.ruleTitle,citation:O.citation.ruleTitle,citations:Di("ruleTitle"),fieldName:"Rule Title",fieldValue:O.ruleTitle})}))]}),(null===(S=null==R?void 0:R.tierOptions)||void 0===S?void 0:S.length)>1&&n.jsx(r.ScopeSection,i.__assign({id:"scope",title:"",required:!1,scopeData:H&&null!==ai?ai:O.scopeData,onScopeChange:function(n,e){H?di(function(t){var o;return i.__assign(i.__assign({},null!=t?t:O.scopeData),((o={})[n]=e,o))}):V.onScopeChange(n,e)},tierLabel:"Which tier are you configuring this learning for?",stationLabel:"Which scope should this learning belong to?",highlights:W,isOpen:k.scopeData,onToggle:function(){return Ii("scopeData")},showCognitiveIcon:O.citation.scopeData,cognitiveIcon:n.jsx(s.ButtonCognitiveIcon,{}),tooltipDescription:"Why this Scope?",errorMessage:(null===(b=R.validationErrors)||void 0===b?void 0:b.station)||(null===(A=R.validationErrors)||void 0===A?void 0:A.tiers),stationErrorMessage:null===(E=R.validationErrors)||void 0===E?void 0:E.station,tierErrorMessage:null===(I=R.validationErrors)||void 0===I?void 0:I.tiers,readOnly:(null==R?void 0:R.isAiStreaming)||!H},R)),O.citation.scopeData&&n.jsx("div",i.__assign({style:ji},{children:n.jsx(t.InputDataReasoningCard,{isVisible:k.scopeData,citation:O.citation.scopeData,citations:Di("scopeData"),fieldName:"Scope",fieldValue:null===(j=null===(D=O.scopeData)||void 0===D?void 0:D.tiers)||void 0===j?void 0:j.join(", ")})})),H?n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"flex-start"}},{children:[B&&n.jsxs("div",i.__assign({style:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:"16px"}},{children:[n.jsx("button",i.__assign({onClick:gi,style:{background:"none",border:"none",color:"var(--il-muted, #64748B)",fontSize:"14px",fontWeight:"500",cursor:"pointer",padding:"0"}},{children:"Discard Changes"})),n.jsxs("button",i.__assign({onClick:fi,disabled:Ti,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",borderRadius:"12px",border:"none",backgroundColor:"var(--il-primary, #2563eb)",color:"var(--il-primary-fg, #ffffff)",fontSize:"14px",fontWeight:"500",cursor:Ti?"not-allowed":"pointer",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",opacity:Ti?.5:1}},{children:[n.jsx(c.Check,{size:18,strokeWidth:2.5,color:"var(--il-primary-fg, #ffffff)"}),"Save Changes"]}))]})),"rule-setup"===(null==R?void 0:R.pendingEditId)&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"10px"}},{children:[n.jsx(c.AlertTriangle,{size:14,style:{color:"var(--il-warning, #C2410C)"}}),n.jsx("div",i.__assign({style:{color:"var(--il-warning, #C2410C)",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]})):null]}))}))})),(!(null==R?void 0:R.tierOptions)||0===R.tierOptions.length)&&n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",padding:"32px 16px",marginTop:"8px",backgroundColor:"var(--il-surface-alt, #f8fafc)",border:"1px dashed var(--il-border, #E2E8F0)",borderRadius:"12px",color:"var(--il-disabled, #94A3B8)"}},{children:[n.jsx(c.AlertTriangle,{size:20,style:{color:"var(--il-disabled, #94A3B8)"}}),n.jsx("span",i.__assign({style:{fontSize:"13px",fontWeight:500,color:"var(--il-muted, #64748B)"}},{children:"No tiers found"}))]})),null===(w=null==R?void 0:R.tierOptions)||void 0===w?void 0:w.map(function(r,s){var p,g,y,_,m,T,C,S=r.toLowerCase().replace(/ /g,"_"),b=(null===(p=O.variantsByTier)||void 0===p?void 0:p[S])||[],A=null===(y=null===(g=O.scopeData)||void 0===g?void 0:g.tiers)||void 0===y?void 0:y.includes(r),E=b.length,I=!1;if(1===E){var D=b[0],j=!(null===(_=null==D?void 0:D.ruleDescription)||void 0===_?void 0:_.trim()),w=(null===(m=null==D?void 0:D.whenToApplyConditions)||void 0===m?void 0:m.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1,W=(null===(T=null==D?void 0:D.whenNotToApplyConditions)||void 0===T?void 0:T.some(function(i){return(null==i?void 0:i.text)&&""!==i.text.trim()}))||!1;!j||w||W||(I=!0)}var N=I?void 0:"".concat(E," ").concat(1===E?"variant":"variants"," configured for this tier"),L=n.jsx(x,i.__assign({onAddVariant:function(){var i;return null===(i=V.addNewVariant)||void 0===i?void 0:i.call(V,S)},isDisabled:!A||(null==R?void 0:R.isAiStreaming),showAddVariantBtn:B&&"Edit"!==(null==R?void 0:R.usedFor)},{children:b.map(function(r,s){var p,g,f,x,y,_,m,T,C,b,E,I=r.variantType||"default",D="".concat(S,"-variant-").concat(s),j=!0===r.is_variant,w="default"===I||"default_variant"===I,W="".concat(S,"_").concat(s),N=P.get(W)||{},L=(null===(g=null===(p=R.separationItemsByTier)||void 0===p?void 0:p[S])||void 0===g?void 0:g.get(s))||[],z=(null===(x=null===(f=R.togglesByTier)||void 0===f?void 0:f[S])||void 0===x?void 0:x.get(s))||[],F=null===(y=null==R?void 0:R.activeEditId)||void 0===y?void 0:y.startsWith("condition-wta-".concat(S,"-").concat(s)),J=null===(_=null==R?void 0:R.activeEditId)||void 0===_?void 0:_.startsWith("condition-wnta-".concat(S,"-").concat(s)),H=!A||r.isReadOnly||(null==R?void 0:R.isAiStreaming),$=w?function(i){return i?i.replace(/_/g," ").replace(/([a-zA-Z])(\d)/g,"$1 $2").replace(/\b\w/g,function(i){return i.toUpperCase()}):"Variant 1"}(I):"".concat((null==R?void 0:R.variantPillLabel)||"Variant"," ").concat(s+1),ti="variant-".concat(S,"-").concat(s),oi=!B&&(null==U?void 0:U.id)===ti,li=Z===ti,ri=oi?U.draft:null,ai=H||li,di=ri?ri.ruleDescription:r.ruleDescription||"",si=ri?ri.instructionPrompt:null!==(m=r.instructionPrompt)&&void 0!==m?m:R.instructionPrompt,ui=h(ri?ri.whenToApplyConditions:r.whenToApplyConditions||[]),ci=h(ri?ri.whenNotToApplyConditions:r.whenNotToApplyConditions||[]),pi=!ri||!v.hasMeaningfulText(ri.ruleDescription)||!ri.whenToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)});return n.jsx("div",i.__assign({ref:function(i){i?K.current.set(D,i):K.current.delete(D)},style:{width:"100%",opacity:A?1:.7},"data-edit-id":B?void 0:ti},{children:n.jsx(d.default,i.__assign({title:{type:w?"default":"variant",label:$,number:s+1,isNewVariant:j,isDefault:r.isDefault,isModified:r.isModified},defaultOpen:!0,expanded:M===D,onToggle:function(){var i,n=M===D;q(n?null:D),null===(i=null==R?void 0:R.setActiveVariantAccordionIndex)||void 0===i||i.call(R,n?null:s)},variant:"rule-behavior",footerData:{ruleTitle:I,description:r.ruleDescription||""},readOnly:H,actionButtons:B?void 0:function(e,t){if(B)return null;if(H&&!oi&&!li)return null;if(oi||li)return n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),ei()},disabled:pi||li,style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10.5px",borderRadius:"6px",border:"1px solid var(--il-primary, #D9D6FE)",backgroundColor:li?"var(--il-primary-subtle, #f5f3ff)":"var(--il-surface, #ffffff)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500,cursor:pi||li?"not-allowed":"pointer",opacity:pi?.5:1}},{children:li?"Validating...":"Save"})),!li&&n.jsx("button",i.__assign({onClick:function(i){i.stopPropagation(),Q()},style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10.5px",borderRadius:"6px",border:"1px solid var(--il-primary, #D9D6FE)",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-primary, #2563EB)",fontSize:"13px",fontWeight:500,cursor:"pointer"}},{children:"Cancel"}))]}));var o=!(v.hasMeaningfulText(r.ruleDescription)||r.whenToApplyConditions&&r.whenToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)})||r.whenNotToApplyConditions&&r.whenNotToApplyConditions.some(function(i){return v.hasMeaningfulText(i.text)}));return n.jsxs("button",i.__assign({title:ai?"Editing unavailable":o?"Add":"Edit",onClick:function(i){i.stopPropagation(),G(r,S,s,$),e||t()},disabled:ai,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",border:"1px solid var(--il-border, #CBD5E1)",borderRadius:"6px",backgroundColor:"var(--il-surface, #ffffff)",color:"var(--il-muted, #64748B)",fontSize:"13px",fontWeight:500,cursor:ai?"not-allowed":"pointer",opacity:ai?.5:1,gap:"6px"}},{children:[n.jsx(u.EditPencilIcon,{size:12})," ",o?"Add":"Edit"]}))},isAiStreaming:null==R?void 0:R.isAiStreaming,alwaysShowActions:!B,showAccentBorder:!mi},{children:n.jsxs("div",i.__assign({style:{display:"flex",flexDirection:"column",gap:"12px"}},{children:[n.jsx(a.TextSection,i.__assign({id:"rule-description-".concat(S,"-").concat(s),title:R.ruleDescriptionTitle||"Rule Description",subtitle:null==R?void 0:R.ruleDescriptionInformation,rows:2,placeholder:"Explain the learning behaviour",required:!0,readOnly:B?H||wi&&(null==R?void 0:R.activeEditId)!=="rule-description-".concat(S,"-").concat(s):H||!oi,value:di,onChange:function(i){return B?V.setRuleDescription(S,s,i):X({ruleDescription:i})},isOpen:k["ruleDescription-".concat(S)],onToggle:function(){return Ii("ruleDescription-".concat(S))},isHighlighted:N.ruleDescription||!1,showCognitiveIcon:null===(T=O.citation)||void 0===T?void 0:T["ruleDescription_".concat(S)],tooltipDescription:"Why this Description?",errorMessage:null===(C=R.validationErrors)||void 0===C?void 0:C["ruleDescription-".concat(S,"-").concat(s)],enableInlineEdit:B,setSendMessageInChat:null==R?void 0:R.setSendMessageInChat,isAiStreaming:null==R?void 0:R.isAiStreaming,fieldName:"Rule Description"},R)),(null===(b=O.citation)||void 0===b?void 0:b["ruleDescription_".concat(S)])&&n.jsx("div",i.__assign({style:ji},{children:n.jsx(t.InputDataReasoningCard,{isVisible:k["ruleDescription-".concat(S)],citation:O.citation["ruleDescription_".concat(S)],citations:Di("ruleDescription_".concat(S,"_").concat(s)),fieldName:"Rule Description",fieldValue:r.ruleDescription})})),n.jsx(o.ConditionSection,i.__assign({id:"when-to-apply-".concat(S,"-").concat(s),idPrefix:"condition-wta",title:R.whenToApplyTitle||"When to apply",subtitle:null==R?void 0:R.wtaInformation,required:!0,dividerRequired:!0,readOnly:B?H||wi&&!F:H,hideEditControls:!B,parentEditing:oi,conditions:ui,onAdd:function(){return B?V.addWhenToApply(S,s):ni("whenToApplyConditions")},onRemove:function(i,n,e){return B?V.removeWhenToApply(i,n,e):ii("whenToApplyConditions",e)},onEdit:function(i,n,e,t){return B?V.editWhenToApply(i,n,e,t):Y("whenToApplyConditions",e,t)},index:s,tierKey:S,isHighlighted:N.wta||!1,highlightedIds:null==R?void 0:R.highlightedIds,tooltipDescription:"Why this Condition?",citations:Di("whenToApply_".concat(S,"_").concat(s)),bordered:!0,addLabel:(null==R?void 0:R.addWhenToApplyBtnLabel)||"Add When to apply",isAiStreaming:R.isAiStreaming,errorMessage:(null===(E=R.validationErrors)||void 0===E?void 0:E["whenToApply-".concat(S,"-").concat(s)])||(null==R?void 0:R.conflictReason)},R)),n.jsx(o.ConditionSection,i.__assign({id:"when-not-to-apply-".concat(S,"-").concat(s),idPrefix:"condition-wnta",title:R.whenNotToApplyTitle||"When NOT to apply",subtitle:null==R?void 0:R.wntaInformation,required:!1,dividerRequired:!0,readOnly:B?H||wi&&!J:H,hideEditControls:!B,parentEditing:oi,conditions:ci,onAdd:function(){return B?V.addWhenNotToApply(S,s):ni("whenNotToApplyConditions")},onRemove:function(i,n,e){return B?V.removeWhenNotToApply(i,n,e):ii("whenNotToApplyConditions",e)},onEdit:function(i,n,e,t){return B?V.editWhenNotToApply(i,n,e,t):Y("whenNotToApplyConditions",e,t)},index:s,tierKey:S,isHighlighted:N.wnta||!1,highlightedIds:null==R?void 0:R.highlightedIds,tooltipDescription:"Why this Condition?",citations:Di("whenNotToApply_".concat(S,"_").concat(s)),bordered:!0,addLabel:(null==R?void 0:R.addWhenNotToApplyBtnLabel)||"Add When NOT to apply",isAiStreaming:R.isAiStreaming},R)),(null==R?void 0:R.LazyPromptEditor)&&n.jsx(e.Suspense,i.__assign({fallback:n.jsx("div",i.__assign({style:{padding:"12px",fontSize:"13px",color:"var(--il-muted, #64748B)"}},{children:"Loading editor..."}))},{children:n.jsx(R.LazyPromptEditor,{id:"instruction-prompt-".concat(S,"-").concat(s),title:R.instructionPromptTitle,description:null==R?void 0:R.promptDescriptionInformation,value:si,onChange:function(i){var n;return B?null===(n=R.setInstructionPrompt)||void 0===n?void 0:n.call(R,i):X({instructionPrompt:i})},readOnly:B?H:H||!oi,hideEditControls:!B,parentEditing:oi,enableViewToggle:null==R?void 0:R.instructionPromptViewToggle,isAiStreaming:null==R?void 0:R.isAiStreaming,tierKey:S,variantIndex:s,uiState:R})})),(null==R?void 0:R.showConfiguration)&&n.jsx(l.ConfigSection,i.__assign({id:"config-".concat(S,"-").concat(s),title:R.configTitle||"Configuration",required:!1,highlights:N,bordered:!0,readOnly:H||wi&&(null==R?void 0:R.activeEditId)!=="config-".concat(S,"-").concat(s),onConfigChange:function(i,n){return V.onConfigChange(S,s,i,n)},separationItems:L,toggles:z,index:s},R)),!B&&oi&&(null==R?void 0:R.pendingEditId)===ti&&n.jsxs("div",i.__assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[n.jsx(c.AlertTriangle,{size:14,style:{color:"var(--il-warning, #C2410C)"}}),n.jsx("div",i.__assign({style:{color:"var(--il-warning, #C2410C)",fontSize:"13px"}},{children:"Pending - Changes not applied yet. Apply or discard them to continue."}))]}))]}))}),D)}),"".concat(S,"-variant-").concat(s))})}));return 1===(null===(C=null==R?void 0:R.tierOptions)||void 0===C?void 0:C.length)?n.jsx(f.default.Fragment,{children:L},"tier-".concat(s)):n.jsx(d.default,i.__assign({variant:"tier-header",title:{type:"other",label:r},subtitle:N,defaultOpen:!0,footerData:{description:"Variants for ".concat(r)}},{children:L}),"tier-".concat(s))})]}))},exports.VariantListWrapper=x;
2
2
  //# sourceMappingURL=CreateRule.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),a=require("@e-llm-studio/audit-log");require("@e-llm-studio/audit-log/dist/styles.css");var o=require("../../../api/transport.js"),r=require("lucide-react"),n=require("./ChangeLogDiff.js"),s=require("react-router-dom"),l=require("../store/useLMSConfigStore.js"),c=require("../RBAC/AccessPanel.module.css.js"),d=require("./AuditLog.module.css.js"),u=require("../store/usePermissionsStore.js"),g=require("../store/useEnvStore.js"),p=require("../store/useConfigStore.js"),h="https://dev.appmod.ai",f=function(e){var i=e.children;return s.useInRouterContext()?t.jsx(t.Fragment,{children:i}):t.jsx(s.MemoryRouter,{children:i})};exports.default=function(s){var x,b,m,v=s.configId,y=s.ruleData,_=s.scopeId,j=s.scopeName,w=(null==j?void 0:j.trim())||"Selected",C=i.useState("scope"),S=C[0],L=C[1];p.useConfigStore.getState().configuration;var T=u.usePermissionsStore(function(e){return e.hasPermission}),A=g.default(function(e){var t;return(null===(t=e.rbacConfig)||void 0===t?void 0:t.applicationResourceId)||""}),k=g.default(function(e){return e.auditLogConfig}),q=Boolean(_&&T("ilotj.scope.changeLog.view",_)),D=Boolean(A&&T("ilotj.application.changeLog.view",A)),I=null!==(x=null==k?void 0:k.baseUrl)&&void 0!==x?x:function(){if("undefined"==typeof window)return h;var e=window.location.origin;return!e||e.includes("local")?h:e}(),E=null!==(b=null==k?void 0:k.fetchEndpoint)&&void 0!==b?b:"/changelog/audit-log/fetch",B=null!==(m=null==k?void 0:k.distinctValuesEndpoint)&&void 0!==m?m:"/changelog/audit-log/distinct-values",F=i.useMemo(function(){var e=[];return _&&e.push(_),e},[y,_]);i.useEffect(function(){console.log("Flattened External Resource IDs:",F)},[F]);var R={configId:v,axiosConfig:o.getAxiosConfig(),getData:{baseUrl:I,endpoint:E},distinctValuesApi:{baseUrl:I,endpoint:B},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t.jsx(r.User,{size:16,color:"var(--eal-muted,#64748b)",style:{flexShrink:0}}),t.jsx("span",e.__assign({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(i){var a,o,r=(a=i.changeTitle,(o=(a||"").toUpperCase()).includes("CREATE")?{color:"var(--il-audit-success-fg, var(--il-success, #2e7d32))",backgroundColor:"var(--il-audit-success-bg, var(--il-success-subtle, #edf7ed))",borderColor:"var(--il-audit-success-border, #c8e6c9)",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:o.includes("UPDATE")||o.includes("TOGGLE")?{color:"var(--il-audit-primary-fg, var(--il-primary, #1565c0))",backgroundColor:"var(--il-audit-primary-bg, var(--il-primary-subtle, #e3f2fd))",borderColor:"var(--il-audit-primary-border, #bbdefb)",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:o.includes("DELETE")?{color:"var(--il-audit-danger-fg, var(--il-danger, #c62828))",backgroundColor:"var(--il-audit-danger-bg, var(--il-danger-subtle, #fdeeed))",borderColor:"var(--il-audit-danger-border, #ffcdd2)",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"var(--eal-text-tertiary,#475569)",backgroundColor:"var(--eal-surface-alt,#f8fafc)",borderColor:"var(--eal-border-strong,#cbd5e1)",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),n=i.changeTitle?i.changeTitle.replace(/_/g," "):"—";return t.jsx("span",e.__assign({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:n}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var i;return t.jsx(n.default,{change:null!==(i=e.actionText)&&void 0!==i?i:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var a,o=(null===(a=i.metadata)||void 0===a?void 0:a.redirect_url)||i.redirect_url;return o?t.jsx("div",e.__assign({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t.jsxs("a",e.__assign({href:o,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--eal-primary,#2563eb)",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t.jsx(r.ExternalLink,{size:14})]}))})):t.jsx("span",e.__assign({style:{color:"var(--eal-disabled,#94a3b8)",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t.jsx("span",e.__assign({style:{color:"var(--eal-disabled,#94a3b8)"}},{children:"—"}));var a=new Date(i.actionDate),o=a.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=a.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"var(--eal-text-tertiary,#475569)"}},{children:[t.jsx("span",e.__assign({style:{fontWeight:500}},{children:o})),t.jsx("span",{children:r})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}};return t.jsx("div",e.__assign({className:d.default.auditLogTheme,style:{height:"100%",overflowY:"auto",background:"var(--il-bg,transparent)"}},{children:t.jsxs("div",e.__assign({style:{padding:"24px"}},{children:[t.jsxs("div",e.__assign({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t.jsx("h1",e.__assign({className:c.default.accessManagementTitle},{children:l.dt("history.title","".concat(w," - Audit Log"),{scope_name:w})})),t.jsx("p",e.__assign({className:c.default.accessManagementSubtitle},{children:l.dt("history.subtitle","Track all learning updates and modifications with the ".concat(w," scope."),{scope_name:w})}))]})),t.jsxs("div",e.__assign({className:c.default.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[t.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":"scope"===S,className:"".concat(c.default.accessTab," ").concat("scope"===S?c.default.accessTabActive:""),onClick:function(){return L("scope")},disabled:!q,title:q?"":"You do not have permission to view scope level change log"},{children:l.dt("history.scopeLevel","Scope Level")})),t.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":"application"===S,className:"".concat(c.default.accessTab," ").concat("application"===S?c.default.accessTabActive:""),onClick:function(){return L("application")},disabled:!D,title:D?"":"You do not have permission to view application level change log"},{children:l.dt("history.applicationLevel","Application Level")}))]})),t.jsx(f,{children:"scope"===S?t.jsx(a.AuditLog,e.__assign({},R,{query:{externalResourceId:F.length>0?F:[""],paginationLimit:10}}),"scope-audit-log"):t.jsx(a.AuditLog,e.__assign({},R,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),a=require("@e-llm-studio/audit-log");require("@e-llm-studio/audit-log/dist/styles.css");var o=require("../../../api/transport.js"),r=require("lucide-react"),n=require("./ChangeLogDiff.js"),s=require("react-router-dom"),l=require("../store/useLMSConfigStore.js"),c=require("../RBAC/AccessPanel.module.css.js"),d=require("./AuditLog.module.css.js"),u=require("../store/usePermissionsStore.js"),g=require("../store/useEnvStore.js"),p=require("../store/useConfigStore.js"),h="https://dev.appmod.ai",f=function(e){var i=e.children;return s.useInRouterContext()?t.jsx(t.Fragment,{children:i}):t.jsx(s.MemoryRouter,{children:i})};exports.default=function(s){var x,b,m,v=s.configId,y=s.accessToken,_=s.ruleData,j=s.scopeId,w=s.scopeName,C=(null==w?void 0:w.trim())||"Selected",S=i.useState("scope"),T=S[0],L=S[1];p.useConfigStore.getState().configuration;var k=u.usePermissionsStore(function(e){return e.hasPermission}),A=g.default(function(e){var t;return(null===(t=e.rbacConfig)||void 0===t?void 0:t.applicationResourceId)||""}),q=g.default(function(e){return e.auditLogConfig}),D=Boolean(j&&k("ilotj.scope.changeLog.view",j)),I=Boolean(A&&k("ilotj.application.changeLog.view",A)),E=null!==(x=null==q?void 0:q.baseUrl)&&void 0!==x?x:function(){if("undefined"==typeof window)return h;var e=window.location.origin;return!e||e.includes("local")?h:e}(),B=null!==(b=null==q?void 0:q.fetchEndpoint)&&void 0!==b?b:"/changelog/audit-log/fetch",F=null!==(m=null==q?void 0:q.distinctValuesEndpoint)&&void 0!==m?m:"/changelog/audit-log/distinct-values",R=i.useMemo(function(){var e=[];return j&&e.push(j),e},[_,j]);i.useEffect(function(){console.log("Flattened External Resource IDs:",R)},[R]);var W={configId:v,accessToken:y,axiosConfig:o.getAxiosConfig(),getData:{baseUrl:E,endpoint:B},distinctValuesApi:{baseUrl:E,endpoint:F},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t.jsx(r.User,{size:16,color:"var(--eal-muted,#64748b)",style:{flexShrink:0}}),t.jsx("span",e.__assign({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(i){var a,o,r=(a=i.changeTitle,(o=(a||"").toUpperCase()).includes("CREATE")?{color:"var(--il-audit-success-fg, var(--il-success, #2e7d32))",backgroundColor:"var(--il-audit-success-bg, var(--il-success-subtle, #edf7ed))",borderColor:"var(--il-audit-success-border, #c8e6c9)",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:o.includes("UPDATE")||o.includes("TOGGLE")?{color:"var(--il-audit-primary-fg, var(--il-primary, #1565c0))",backgroundColor:"var(--il-audit-primary-bg, var(--il-primary-subtle, #e3f2fd))",borderColor:"var(--il-audit-primary-border, #bbdefb)",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:o.includes("DELETE")?{color:"var(--il-audit-danger-fg, var(--il-danger, #c62828))",backgroundColor:"var(--il-audit-danger-bg, var(--il-danger-subtle, #fdeeed))",borderColor:"var(--il-audit-danger-border, #ffcdd2)",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"var(--eal-text-tertiary,#475569)",backgroundColor:"var(--eal-surface-alt,#f8fafc)",borderColor:"var(--eal-border-strong,#cbd5e1)",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),n=i.changeTitle?i.changeTitle.replace(/_/g," "):"—";return t.jsx("span",e.__assign({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:n}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var i;return t.jsx(n.default,{change:null!==(i=e.actionText)&&void 0!==i?i:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var a,o=(null===(a=i.metadata)||void 0===a?void 0:a.redirect_url)||i.redirect_url;return o?t.jsx("div",e.__assign({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t.jsxs("a",e.__assign({href:o,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--eal-primary,#2563eb)",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t.jsx(r.ExternalLink,{size:14})]}))})):t.jsx("span",e.__assign({style:{color:"var(--eal-disabled,#94a3b8)",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t.jsx("span",e.__assign({style:{color:"var(--eal-disabled,#94a3b8)"}},{children:"—"}));var a=new Date(i.actionDate),o=a.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=a.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"var(--eal-text-tertiary,#475569)"}},{children:[t.jsx("span",e.__assign({style:{fontWeight:500}},{children:o})),t.jsx("span",{children:r})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}};return t.jsx("div",e.__assign({className:d.default.auditLogTheme,style:{height:"100%",overflowY:"auto",background:"var(--il-bg,transparent)"}},{children:t.jsxs("div",e.__assign({style:{padding:"24px"}},{children:[t.jsxs("div",e.__assign({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t.jsx("h1",e.__assign({className:c.default.accessManagementTitle},{children:l.dt("history.title","".concat(C," - Audit Log"),{scope_name:C})})),t.jsx("p",e.__assign({className:c.default.accessManagementSubtitle},{children:l.dt("history.subtitle","Track all learning updates and modifications with the ".concat(C," scope."),{scope_name:C})}))]})),t.jsxs("div",e.__assign({className:c.default.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[t.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":"scope"===T,className:"".concat(c.default.accessTab," ").concat("scope"===T?c.default.accessTabActive:""),onClick:function(){return L("scope")},disabled:!D,title:D?"":"You do not have permission to view scope level change log"},{children:l.dt("history.scopeLevel","Scope Level")})),t.jsx("button",e.__assign({type:"button",role:"tab","aria-selected":"application"===T,className:"".concat(c.default.accessTab," ").concat("application"===T?c.default.accessTabActive:""),onClick:function(){return L("application")},disabled:!I,title:I?"":"You do not have permission to view application level change log"},{children:l.dt("history.applicationLevel","Application Level")}))]})),t.jsx(f,{children:"scope"===T?t.jsx(a.AuditLog,e.__assign({},W,{query:{externalResourceId:R.length>0?R:[""],paginationLimit:10}}),"scope-audit-log"):t.jsx(a.AuditLog,e.__assign({},W,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")})]}))}))};
2
2
  //# sourceMappingURL=AuditLog.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),o=require("./RuleContent/RuleContent.js"),s=require("./StationsContent/StationsContent.js"),a=require("./RBAC/AccessManagementPanel.js");require("appsec-ui"),require("../../api/transport.js"),require("./store/useAuthStore.js"),require("./store/usePermissionsStore.js");var i=require("./store/useLearningTemplateStore.js"),r=require("./store/useEnvStore.js");require("../IL-marketplace/marketplaceTheme.js");var c=require("./styles/LearningTemplateLayout.module.css.js"),u=require("./utils/treeUtils.js"),l=require("./SidebarWrapper.js"),d=require("./components/StationOnboarding/StationOnboardModal.js"),p=require("./AuditLog/AuditLog.js"),S=require("./components/EmptyLearningState.js"),f=require("./store/useLMSConfigStore.js"),g=require("./constants.js"),m=require("../IL-marketplace/components/GuidelineLibraryContent.js"),T=require("./HumanChanges/HumanChange.js"),_=require("./hooks/useLearningTemplateQueryParams.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=A(t);exports.default=function(A){var h,q,j=A.onOpenCreateModal,C=A.onRefreshRuleSets,R=A.scopeTreeData,L=A.onAddChild,E=A.onRenameChild,M=A.onDeleteChild,x=A.canDeleteScope,D=A.canEditScope,P=A.canCreateScope,I=A.onSectionSelect,y=A.onViewStation,w=A.activeSectionId,b=void 0===w?"learnings":w,k=A.sectionsConfig,O=A.nodeTypesConfig,Y=A.app_integration_id,H=A.token,N=A.modeId,B=A.onRequestAccess,U=A.isRequestingAccess,G=A.isAccessRequested,Q=A.selectionMode,V=void 0!==Q&&Q,K=A.isILMarketplace,W=A.children,z=A.guidelineContentProps,F=A.humanChanges,J=A.menuActionsConfig,X=i.useLearningTemplateStore(function(e){return e.isStationModalOpen}),Z=i.useLearningTemplateStore(function(e){return e.setStationModalOpen}),$=i.useLearningTemplateStore(function(e){return e.isStationOnboardModalTriggered}),ee=i.useLearningTemplateStore(function(e){return e.setIsStationOnboardModalTriggered}),ne=i.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),te=i.useLearningTemplateStore(function(e){return e.rawAuditRuleData}),oe=r.default(function(e){return e.auditLogConfig});i.useLearningTemplateStore(function(e){return e.ruleData});var se=t.useState(null),ae=se[0],ie=se[1],re=ne?u.findNodeById((null==R?void 0:R.data)||null,ne):null;Boolean((null===(h=null==R?void 0:R.data)||void 0===h?void 0:h.id)&&ne===R.data.id);var ce=new URLSearchParams(window.location.search);t.useEffect(function(){var e=ce.get(_.QUERY_PARAM_KEYS.RULESET_ID);ie(e)},[ce]);var ue=v.default.useMemo(function(){return F&&ae?e.__assign(e.__assign({},F),{query:e.__assign(e.__assign({},F.query),{scopeId:[ae]})}):F},[F,ae]);return t.useEffect(function(){$&&Z(!0)},[$,Z,ee]),n.jsxs("div",e.__assign({className:"".concat(c.default.container," ").concat(V?c.default.containerSelectionMode:"")},{children:[n.jsx(l.default,{onOpenCreateModal:j,onRefreshRuleSets:C,scopeTreeData:R,onAddChild:L,onRenameChild:E,onDeleteChild:M,canDeleteScope:x,canEditScope:D,canCreateScope:P,onSectionSelect:I,activeSectionId:b,sectionsConfig:k,nodeTypesConfig:O,menuActionsConfig:J}),n.jsx("div",e.__assign({id:"rule-template-layout-content",className:"".concat(c.default.content," relative flex-1 overflow-hidden")},{children:"stations"===b?n.jsx(s.default,{scopeId:ne||"",scopeName:(null==re?void 0:re.name)||"Unknown Scope",stationsCount:null===(q=null==re?void 0:re.metrics)||void 0===q?void 0:q.stationsCount,stations:u.mapScopeChildrenToStations(re),onViewStation:y}):"access"===b?n.jsx(a.default,{selectedRuleSetId:ne,scopeName:(null==re?void 0:re.name)||"Unknown Scope"}):"history"===b?(null==oe?void 0:oe.configId)?n.jsx(p.default,{configId:oe.configId,scopeId:ne||void 0,scopeName:(null==re?void 0:re.name)||"Unknown Scope",ruleData:te}):null:"human-changes"===b?ue?n.jsx(T.HumanChange,{humanChanges:ue}):n.jsx("div",e.__assign({className:"flex items-center justify-center h-full"},{children:n.jsx("p",e.__assign({className:"text-gray-500"},{children:"No human changes configuration provided."}))})):re&&!1===re.hasAccess?n.jsx(S.default,{onCreate:function(){},title:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),desc:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==re?void 0:re.name," learnings.")),button:"",canCreateRule:!1,noAccessTitle:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),noAccessDesc:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==re?void 0:re.name," learnings.")),requestAccessButton:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".requestAccessButton"),"Request Access"),requestSentButton:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return null==B?void 0:B(ne)},isRequestingAccess:U,isAccessRequested:G}):W||(K?z?n.jsx(m.GuidelineLibraryContent,e.__assign({},z)):null:n.jsx(o.default,{onRefreshRuleSets:C,app_integration_id:Y,token:H,modeId:N}))})),n.jsx(d.default,{isOpen:X,onClose:function(){Z(!1),ee(!1)},onBoardStation:function(e){C(!0,e)},app_integration_id:Y,token:H})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),o=require("./RuleContent/RuleContent.js"),s=require("./StationsContent/StationsContent.js"),a=require("./RBAC/AccessManagementPanel.js");require("appsec-ui"),require("../../api/transport.js"),require("./store/useAuthStore.js"),require("./store/usePermissionsStore.js");var i=require("./store/useLearningTemplateStore.js"),r=require("./store/useEnvStore.js");require("../IL-marketplace/marketplaceTheme.js");var c=require("./styles/LearningTemplateLayout.module.css.js"),u=require("./utils/treeUtils.js"),l=require("./SidebarWrapper.js"),d=require("./components/StationOnboarding/StationOnboardModal.js"),p=require("./AuditLog/AuditLog.js"),S=require("./components/EmptyLearningState.js"),f=require("./store/useLMSConfigStore.js"),g=require("./constants.js"),m=require("../IL-marketplace/components/GuidelineLibraryContent.js"),T=require("./HumanChanges/HumanChange.js"),_=require("./hooks/useLearningTemplateQueryParams.js");function A(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=A(t);exports.default=function(A){var h,q,j=A.onOpenCreateModal,C=A.onRefreshRuleSets,R=A.scopeTreeData,L=A.onAddChild,E=A.onRenameChild,M=A.onDeleteChild,x=A.canDeleteScope,D=A.canEditScope,P=A.canCreateScope,I=A.onSectionSelect,y=A.onViewStation,k=A.activeSectionId,w=void 0===k?"learnings":k,b=A.sectionsConfig,O=A.nodeTypesConfig,Y=A.app_integration_id,H=A.token,N=A.modeId,B=A.onRequestAccess,U=A.isRequestingAccess,G=A.isAccessRequested,Q=A.selectionMode,V=void 0!==Q&&Q,K=A.isILMarketplace,W=A.children,z=A.guidelineContentProps,F=A.humanChanges,J=A.menuActionsConfig,X=i.useLearningTemplateStore(function(e){return e.isStationModalOpen}),Z=i.useLearningTemplateStore(function(e){return e.setStationModalOpen}),$=i.useLearningTemplateStore(function(e){return e.isStationOnboardModalTriggered}),ee=i.useLearningTemplateStore(function(e){return e.setIsStationOnboardModalTriggered}),ne=i.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),te=i.useLearningTemplateStore(function(e){return e.rawAuditRuleData}),oe=r.default(function(e){return e.auditLogConfig});i.useLearningTemplateStore(function(e){return e.ruleData});var se=t.useState(null),ae=se[0],ie=se[1],re=ne?u.findNodeById((null==R?void 0:R.data)||null,ne):null;Boolean((null===(h=null==R?void 0:R.data)||void 0===h?void 0:h.id)&&ne===R.data.id);var ce=new URLSearchParams(window.location.search);t.useEffect(function(){var e=ce.get(_.QUERY_PARAM_KEYS.RULESET_ID);ie(e)},[ce]);var ue=v.default.useMemo(function(){return F&&ae?e.__assign(e.__assign({},F),{query:e.__assign(e.__assign({},F.query),{scopeId:[ae]})}):F},[F,ae]);return t.useEffect(function(){$&&Z(!0)},[$,Z,ee]),n.jsxs("div",e.__assign({className:"".concat(c.default.container," ").concat(V?c.default.containerSelectionMode:"")},{children:[n.jsx(l.default,{onOpenCreateModal:j,onRefreshRuleSets:C,scopeTreeData:R,onAddChild:L,onRenameChild:E,onDeleteChild:M,canDeleteScope:x,canEditScope:D,canCreateScope:P,onSectionSelect:I,activeSectionId:w,sectionsConfig:b,nodeTypesConfig:O,menuActionsConfig:J}),n.jsx("div",e.__assign({id:"rule-template-layout-content",className:"".concat(c.default.content," relative flex-1 overflow-hidden")},{children:"stations"===w?n.jsx(s.default,{scopeId:ne||"",scopeName:(null==re?void 0:re.name)||"Unknown Scope",stationsCount:null===(q=null==re?void 0:re.metrics)||void 0===q?void 0:q.stationsCount,stations:u.mapScopeChildrenToStations(re),onViewStation:y}):"access"===w?n.jsx(a.default,{selectedRuleSetId:ne,scopeName:(null==re?void 0:re.name)||"Unknown Scope"}):"history"===w?(null==oe?void 0:oe.configId)?n.jsx(p.default,{configId:oe.configId,accessToken:H,scopeId:ne||void 0,scopeName:(null==re?void 0:re.name)||"Unknown Scope",ruleData:te}):null:"human-changes"===w?ue?n.jsx(T.HumanChange,{humanChanges:ue}):n.jsx("div",e.__assign({className:"flex items-center justify-center h-full"},{children:n.jsx("p",e.__assign({className:"text-gray-500"},{children:"No human changes configuration provided."}))})):re&&!1===re.hasAccess?n.jsx(S.default,{onCreate:function(){},title:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),desc:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==re?void 0:re.name," learnings.")),button:"",canCreateRule:!1,noAccessTitle:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessTitle"),"Access Restricted"),noAccessDesc:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".noAccessDesc"),"You do not have access to view this ".concat(null==re?void 0:re.name," learnings.")),requestAccessButton:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".requestAccessButton"),"Request Access"),requestSentButton:f.dt("".concat(g.EMPTY_STATE_DT_PATH,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return null==B?void 0:B(ne)},isRequestingAccess:U,isAccessRequested:G}):W||(K?z?n.jsx(m.GuidelineLibraryContent,e.__assign({},z)):null:n.jsx(o.default,{onRefreshRuleSets:C,app_integration_id:Y,token:H,modeId:N}))})),n.jsx(d.default,{isOpen:X,onClose:function(){Z(!1),ee(!1)},onBoardStation:function(e){C(!0,e)},app_integration_id:Y,token:H})]}))};
2
2
  //# sourceMappingURL=LearningTemplateLayout.js.map