@e-llm-studio/instant-learning 0.1.1-alpha.12 → 0.1.1-alpha.14
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/dist/6fbbe065ef78c384.gif +0 -0
- package/dist/cjs/6fbbe065ef78c384.gif +0 -0
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/cjs/features/LearningManagement/apis/apiConfig.js +1 -1
- package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +2 -0
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js.map +1 -0
- package/dist/cjs/features/LearningManagement/config.js +2 -0
- package/dist/cjs/features/LearningManagement/config.js.map +1 -0
- package/dist/cjs/features/LearningManagement/public/ThinkingBulbIcon.gif.js +2 -0
- package/dist/cjs/features/LearningManagement/public/ThinkingBulbIcon.gif.js.map +1 -0
- package/dist/cjs/features/LearningManagement/store/useLearningTemplateStore.js +1 -1
- package/dist/cjs/features/LearningManagement/styles/InstantLearningModal.module.css.js +2 -0
- package/dist/cjs/features/LearningManagement/styles/InstantLearningModal.module.css.js.map +1 -0
- package/dist/cjs/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.js +1 -1
- package/dist/cjs/plugins/valueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js +2 -0
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js +1 -1
- package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/features/LearningManagement/apis/apiConfig.js +1 -1
- package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +2 -0
- package/dist/features/LearningManagement/components/InstantLearningModal.js.map +1 -0
- package/dist/features/LearningManagement/config.js +2 -0
- package/dist/features/LearningManagement/config.js.map +1 -0
- package/dist/features/LearningManagement/public/ThinkingBulbIcon.gif.js +2 -0
- package/dist/features/LearningManagement/public/ThinkingBulbIcon.gif.js.map +1 -0
- package/dist/features/LearningManagement/store/useLearningTemplateStore.js +1 -1
- package/dist/features/LearningManagement/styles/InstantLearningModal.module.css.js +2 -0
- package/dist/features/LearningManagement/styles/InstantLearningModal.module.css.js.map +1 -0
- package/dist/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.js +1 -1
- package/dist/plugins/valueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js +2 -0
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts +20 -3
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/store/useLearningTemplateStore.d.ts +2 -0
- package/dist/types/src/features/LearningManagement/store/useLearningTemplateStore.d.ts.map +1 -1
- package/dist/types/src/plugins/valueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.d.ts +4 -0
- package/dist/types/src/plugins/valueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js +0 -2
- package/dist/plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js +0 -2
- package/dist/types/src/plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.d.ts +0 -28
- package/dist/types/src/plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.d.ts.map +0 -1
- /package/dist/cjs/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.js.map +0 -0
- /package/dist/cjs/plugins/{ValueTypes → valueTypes}/RadioTrafficLearning/RadioTrafficLearningRenderer.js.map +0 -0
- /package/dist/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.js.map +0 -0
- /package/dist/plugins/{ValueTypes → valueTypes}/RadioTrafficLearning/RadioTrafficLearningRenderer.js.map +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Category/CategoryTeachMeRenderer.d.ts +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Category/CategoryTeachMeRenderer.d.ts.map +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.d.ts +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Default/DefaultTeachMeRenderer.d.ts.map +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Guidelines/GuidelinesTeachMeRenderer.d.ts +0 -0
- /package/dist/types/src/plugins/{ValueTypes → valueTypes}/Guidelines/GuidelinesTeachMeRenderer.d.ts.map +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react");require("../../../features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../../../features/IL-OTJ/_components/InputDataReasoningCard.js"),require("../../../features/IL-OTJ/_components/TooltipComponent.js");var a=require("../../../features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");require("../../../features/IL-OTJ/store/CitationsContext.js"),require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../../features/IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../../features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../../features/IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("@viswa-test/test-citation"),require("../../../features/LearningManagement/store/useLearningTemplateStore.js"),require("primereact/toast"),require("../../../features/LearningManagement/apis/scopeApis.js"),require("../../../features/LearningManagement/components/ToolTip.js"),require("../../../features/LearningManagement/store/useAuthStore.js"),require("date-fns"),require("framer-motion");var o=require("../../../features/IL-OTJ/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react");require("../../../features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../../../features/IL-OTJ/_components/InputDataReasoningCard.js"),require("../../../features/IL-OTJ/_components/TooltipComponent.js");var a=require("../../../features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");require("../../../features/IL-OTJ/store/CitationsContext.js"),require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../../features/IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../../features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../../features/IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("@viswa-test/test-citation"),require("../../../features/LearningManagement/store/useLearningTemplateStore.js"),require("primereact/toast"),require("../../../features/LearningManagement/apis/scopeApis.js"),require("../../../features/LearningManagement/components/ToolTip.js"),require("../../../features/LearningManagement/store/useAuthStore.js"),require("date-fns"),require("framer-motion"),require("@mui/icons-material/Close");var o=require("../../../features/IL-OTJ/_components/AccordianSection.js"),i=require("../../../features/IL-OTJ/ILOTJ.js");require("../../../features/LearningManagement/store/useConfigStore.js"),require("@radix-ui/react-tooltip"),require("../../../features/LearningManagement/components/StationOnboarding/InputField.js"),require("../../../features/LearningManagement/store/useEnvStore.js");var s={order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1},is_default_enabled:!1},l=[{label:"Global Scope",value:"global"},{label:"Genre Scope",value:"genre"},{label:"Custom Scope",value:"custom"}],u=["Tier 1"];exports.default=function(){var c=n.useState(!0),d=c[0],p=c[1],_=n.useState(""),m=_[0],g=_[1],f=n.useState(""),b=f[0],v=f[1],h=n.useState({station:"",tiers:["Tier 1"]}),y=h[0],T=h[1],k=n.useState([]),q=k[0],w=k[1],L=n.useState([]),C=L[0],x=L[1],j=n.useState(s),S=j[0],I=j[1],A=n.useCallback(function(t,n){T(function(r){var a;return e.__assign(e.__assign({},r),((a={})[t]=n,a))})},[]),O=n.useCallback(function(t,n){I(function(r){var a=e.__assign({},r);switch(t){case"order_rules":case"advertiser_rules":a[t]="boolean"==typeof n?e.__assign(e.__assign({},r[t]),{enabled:n}):{enabled:n.enabled,global_min_separation_seconds:n.global_min_separation_seconds};break;case"inventory_rules":a.inventory_rules={respect_inventory_code:"boolean"==typeof n?n:n.respect_inventory_code};break;case"break_code_rules":a.break_code_rules={respect_break_code:"boolean"==typeof n?n:n.respect_break_code};break;case"is_default_enabled":a.is_default_enabled="boolean"==typeof n?n:!!n}return a})},[]),M=function(t){t(function(t){return e.__spreadArray(e.__spreadArray([],t,!0),[{id:Date.now(),text:"",reasoning:""}],!1)})},N=function(e,t){e(function(e){return e.filter(function(e){return e.id!==t})})},E=function(t,n,r){t(function(t){return t.map(function(t){return String(t.id)===String(n)?e.__assign(e.__assign({},t),{text:r}):t})})},J=[e.__assign({key:"order_rules",label:"Order"},S.order_rules),e.__assign({key:"advertiser_rules",label:"Advertiser"},S.advertiser_rules)],D=[{key:"inventory_rules",label:"Inventory code",enabled:S.inventory_rules.respect_inventory_code},{key:"break_code_rules",label:"Break Code",enabled:S.break_code_rules.respect_break_code},{key:"is_default_enabled",label:"Default Variant",enabled:S.is_default_enabled}],W={"Separation rule":"I would want to add a separation rule","Max priority rule":"I would want to set a max priority rule","Break code matching":"I would want to add a break code matching rule","Inventory code matching":"I would want to add a inventory window matching rule","Enter a rule description":"I want to add a rule description","Tester Genie":"Loading prompt..."},B="<p><span>Hi! 👋 I'm your Instant Learning Concierge.</span>\n <span>How would you like to get started? You can select an option below or describe the rule you’d like to create.</span>\n ".concat(["Separation rule","Max priority rule","Break code matching","Inventory code matching","Enter a rule description","Tester Genie"].map(function(e){return'<button class="clickable-button" data-value="'.concat(W[e],'">').concat(e,"</button>")}).join(""),"</p>");return t.jsx(i.default,{open:d,closeFunction:function(){return p(!1)},chatAssistantName:"defaultAssistant",organizationName:"techolution",baseUrl:"https://devllmstudio.creativeworkspace.ai",baseWebsocketUrl:"wss://devllmstudio.creativeworkspace.ai/graphql",ThinkingBulbIconComponent:t.jsx(r.Lightbulb,{}),customSections:t.jsx(t.Fragment,{}),isUseNormalChat:!0,chatTitle:"Create New Learning",formTitle:"Learning Details",initialChatMessage:B,template:a.TemplateList.BaseTemplate,templateProps:{state:{title:m,description:b,scopeData:y,whenToApplyConditions:q,whenNotToApplyConditions:C,configData:S,citations:[],citation:{}},handlers:{onTitleChange:function(e){var t,n;return g(null!==(n=null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)&&void 0!==n?n:e)},onDescriptionChange:function(e){var t,n;return v(null!==(n=null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.value)&&void 0!==n?n:e)},onAddWhenToApply:function(){return M(w)},onRemoveWhenToApply:function(e){return N(w,e)},onEditWhenToApply:function(e,t){return E(w,e,t)},onAddWhenNotToApply:function(){return M(x)},onRemoveWhenNotToApply:function(e){return N(x,e)},onEditWhenNotToApply:function(e,t){return E(x,e,t)},onScopeChange:A,onConfigChange:O},uiState:{showScope:!1,showConfiguration:!0,titleLabel:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tier",descriptionLabel:"Learning Explanation",whenToApplyLabel:"Trigger Events (When to Apply)",whenNotToApplyLabel:"Exclusion Events (When NOT to Apply)",configLabel:"Advanced Settings",stationOptions:l,tierOptions:u,separationItems:J,toggles:D},customNodes:{afterDescription:t.jsx(o.default,e.__assign({title:{type:"other",label:"Extra Context Panel"}},{children:t.jsx("p",e.__assign({style:{padding:"12px",fontSize:"14px",color:"#64748b"}},{children:"Because you decoupled the template, I can inject anything I want here without touching BaseTemplate logic!"}))})),afterTitle:t.jsxs("div",e.__assign({style:{marginBottom:"12px",padding:"8px",backgroundColor:"#f0f4ff",borderRadius:"4px"}},{children:[t.jsx("strong",{children:"Tip:"})," Use a clear and descriptive title for your rule to make it easily identifiable later."]}))}}})};
|
|
2
2
|
//# sourceMappingURL=DefaultTeachMeRenderer.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("../../../features/LearningManagement/components/InstantLearningModal.js");exports.default=function(r){return e.jsx(i.default,{isOpen:r.isOpen,onClose:r.onClose,initialScope:r.initialScope,ruleSet:r.ruleSet,editingRule:r.editingRule,editingTier:r.editingTier,editingVariants:r.editingVariants,focusedVariantIndex:r.focusedVariantIndex,setFocusedVariantIndex:r.setFocusedVariantIndex,triggerAddVariant:r.triggerAddVariant,triggerFixGaps:r.triggerFixGaps,copiedRule:r.copiedRule,copiedSourceTier:r.copiedSourceTier,copiedTargetTier:r.copiedTargetTier,initialDraftMessage:r.initialDraftMessage})};
|
|
2
|
+
//# sourceMappingURL=RadioTrafficLearningRenderer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as e,__awaiter as i,__generator as t}from"tslib";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as l}from"react";import{Box as o,CircularProgress as s,Dialog as c,DialogTitle as u,Typography as p,IconButton as d,DialogContent as I}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";import b from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import f from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";var W=function(e,n){return i(void 0,void 0,void 0,function(){var i,r;return t(this,function(t){switch(t.label){case 0:return[4,fetch("".concat("https://devllmstudio.creativeworkspace.ai","/instant_learning/ilotj/application/getValueType/").concat(e),{headers:{Authorization:"Bearer ".concat(n)}})];case 1:if(!(i=t.sent()).ok)throw new Error("Failed to fetch value type");return[4,i.json()];case 2:return r=t.sent(),console.log("Fetched value type data:",r),!r||Array.isArray(r.data)&&0===r.data.length?[2,null]:[2,r.data[0].value_type_name||r.valueTypeName||r.templateName]}})})},Z=function(){var i=a(!0),t=i[0],l=i[1];return r(c,e({open:t,onClose:function(){return l(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[r(u,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[n(p,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),n(d,e({onClick:function(){return l(!1)}},{children:n(m,{})}))]})),n(I,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},O=function(r){var c=h(function(e){return e.templateMap[r.app_integration_id]}),u=h(function(e){return e.setTemplateData}),p=a(!0),d=p[0],I=p[1],m=a(!1),O=m[0],g=m[1];if(l(function(){if(r.isOpen&&r.app_integration_id)if(c)I(!1);else{i(void 0,void 0,void 0,function(){var e,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,3,4]),I(!0),g(!1),[4,W(r.app_integration_id,"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25uZWN0b3JNYXAiOnt9LCJfaWQiOiI2OGI5OTExMWY1YWYyNzkwYTViN2Q3NzEiLCJlbWFpbCI6Im1vaGFtbWVkLmZhaXp1ZGRpbkB0ZWNob2x1dGlvbi5jb20iLCJmaXJzdG5hbWUiOiJNb2hhbW1lZCIsImxhc3RuYW1lIjoiRmFpenVkZGluIiwicm9sZSI6WyI2OTQwMWNmZTMwMzg5ODMwZWRlZDU4YmYiLCI2OGVmYjhiNTBhN2UwZWZlZTc5NTFhNWQiLCI2OTBiNmUwYmY3OGVmNTYyNzMxMzY0MTEiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOTgiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOWEiLCI2ODk5YzFlNmFkOWQwOGRhZGQxYzVlOTYiLCI2ODk5YzUyMjRkNmRjNDFjZDFmYjc5NWEiLCI2ODk5YzMzYWU5ZmQ0MWYzZjkwOGVkZDAiXSwiZGVwYXJ0bWVudHMiOltdLCJzdGF0dXMiOiJBQ1RJVkUiLCJyZXNldF90b2tlbiI6bnVsbCwiY3JlYXRlZEF0IjoiMjAyNS0wOS0wNFQxMzoxNjowMS43OThaIiwiam9pbmVkT24iOiIyMDI1LTA5LTA0VDEzOjE2OjAxLjc5OFoiLCJ1c2VyVmFsaWRpdHkiOiIyMDI1LTExLTE0VDE1OjA3OjM0LjE1NVoiLCJlbXBsb3llbWVudFR5cGUiOiJJbnRlcm4iLCJkZXNpZ25hdGlvbiI6IkZ1bGwgU3RhY2sgRGV2ZWxvcGVyIC0gSW50ZXJuIiwiZGVwYXJ0bWVudCI6IkRpZ2l0YWwgVHJhbnNmb3JtYXRpb24iLCJlbXBsb3llZUlkIjoiSU5UMDU0MiIsIm9yZ2FuaXphdGlvbiI6W10sImdyb3VwcyI6W10sInJvbGVuYW1lIjpbIk9yZyBVc2VyIiwiQ29udGV4dElMTW9kZSBBZG1pbiIsIkFnZW50IEdlbmllIE1vZGUgVXNlciIsIkFnZW50IEdlbmllIE1vZGUgQWRtaW4iLCJUZXN0IElMIC0gRmFpeiBBZG1pbiIsIk9iamVjdCBEZXRlY3Rpb24gTW9kZSBUZXN0IEFkbWluIiwiQWdlbnQgR2VuaWUgTW9kZSBNYW5hZ2VyIiwiT3JnIEFkbWluIl0sImlhdCI6MTc3OTA5MjI3NSwiZXhwIjoxNzc5MjY1MDc1fQ.De1vmWMkbC0xLE1JAHejXHCOcdZ4CCUCfeFl_LcMWBk")];case 1:return e=t.sent(),u(r.app_integration_id,e),[3,4];case 2:return i=t.sent(),console.error(i),g(!0),u(r.app_integration_id,"ERROR"),[3,4];case 3:return I(!1),[7];case 4:return[2]}})})}},[r.isOpen,r.app_integration_id,c]),console.log("hi hello",r.app_integration_id),d)return n(o,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(s,{size:32})}));if(O)return n(Z,{});switch(c){case"Default":return n(b,{});case"Radio Traffic Learning":return n(f,e({},r));default:return n(Z,{})}};export{O as default};
|
|
2
2
|
//# sourceMappingURL=TeachMeWrapper.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as r}from"tslib";import{jsxs as n,Fragment as o,jsx as i}from"react/jsx-runtime";import{useRef as a,useState as l,useEffect as s}from"react";import{useLearningTemplateStore as u}from"../store/useLearningTemplateStore.js";import c from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as d,exportRuleSet as p,deleteRule as m,deleteQuestion as v,alterQuestionPriority as f}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as y}from"primereact/toast";import g from"./ContentLogic.js";import T from"../components/ErrorStateDisplay.js";import w from"../shared/SuccessToastContent.js";import b from"../shared/ErrorToastContent.js";import{findNodeById as _}from"../utils/treeUtils.js";import S from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as C}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import R from"../../IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useAuthStore.js";import"../store/useConfigStore.js";import"../store/useEnvStore.js";var j=function(j){var k,M=j.noRulesTitle,L=void 0===M?"No rules have been added !":M,N=j.noRulesDesc,O=void 0===N?"Start by adding rules that should apply across all stations.":N,D=j.noRulesButtonText,A=void 0===D?"Create New Rule":D,x=j.deleteRuleSuccessMessage,E=void 0===x?"Rule deleted successfully!":x,F=j.deleteVariantSuccessMessage,V=void 0===F?"Variant deleted successfully!":F,J=j.deleteRuleErrorMessage,B=void 0===J?"Failed to delete rule. Please try again.":J,U=j.deleteVariantErrorMessage,W=void 0===U?"Failed to delete variant. Please try again.":U,P=j.deleteModalTitle,G=void 0===P?"Delete":P,K=j.deleteRuleModalWarning,q=void 0===K?"This will permanently delete the rule configuration.":K,H=j.deleteVariantModalWarning,z=void 0===H?"This will permanently delete the variant configuration.":H,Q=j.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=j.onRefreshRuleSets,Z=j.app_integration_id,$=j.token,ee=u(function(e){return e.selectedRuleSetId}),te=u(function(e){return e.scopeTreeData});u(function(e){return e.sidebarTab});var re=u(function(e){return e.setInitialRules}),ne=u(function(e){return e.currentRules});u(function(e){return e.createdVariantInfo});var oe=u(function(e){return e.resetCreatedVariantInfo}),ie=u(function(e){return e.isILModalTriggered});u(function(e){return e.setIsILModalTriggered});var ae=a(null),le=l(!1),se=le[0],ue=le[1],ce=l(null);ce[0];var de=ce[1],pe=l(null);pe[0];var me=pe[1],ve=l(null);ve[0];var fe=ve[1],he=l(null);he[0];var ye=he[1],ge=l(!1),Te=ge[0],we=ge[1],be=l(null),_e=be[0],Se=be[1],Ie=l(!1),Ce=Ie[0],Re=Ie[1],je=l("");je[0];var ke=je[1],Me=l(null),Le=Me[0],Ne=Me[1],Oe=l(!1),De=Oe[0],Ae=Oe[1],xe=l(!1);xe[0];var Ee=xe[1],Fe=l("ruleDeletion"),Ve=Fe[0],Je=Fe[1],Be=l(null),Ue=Be[0],We=Be[1],Pe=l(!1),Ge=Pe[0],Ke=Pe[1],qe=l(!1);qe[0];var He=qe[1],ze=u.getState().tiers,Qe=l(null);Qe[0];var Xe=Qe[1],Ye=l(null);Ye[0];var Ze=Ye[1],$e=l(null);$e[0];var et=$e[1],tt=function(){de(null),me(null),ue(!0),ye(0)};s(function(){rt()},[ee,re]),s(function(){ie&&ue(!0)},[ie]);var rt=function(n){return void 0===n&&(n=!1),e(void 0,void 0,void 0,function(){var e,o,i,a,l,s,c,p,m,v,f,h,y,g,T,w,b,_,S;return t(this,function(t){switch(t.label){case 0:if(!ee)return re([]),[2];n||we(!0),Se(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,d(ee,$)];case 2:return t.sent(),e={data:{ruleSetName:"KRMN",ruleSetDesc:null,created_at:"Fri, 15 May 2026 11:22:09 GMT",updated_at:"Fri, 15 May 2026 11:22:09 GMT",created_by:"lokesh.choraria@techolution.com",updated_by:"lokesh.choraria@techolution.com",lowpriority:[{ruleId:"019e2b65-cec4-7d82-a3b0-8c94553e0e48",ruleTitle:"Advertiser Separation Rule",variants:[{variantId:"019e2b65-ba85-7906-af38-b916d612fbbe",description:"Variant A",whenToApply:"Apply when advertiser separation is enabled.",whenNotToApply:"Do not apply during emergency override.",variantType:"default",link_id:"019e1e39-2030-7775-8312-0ad525700588",dataSource:{type:"",ref:"",tag:""},is_enabled:!0,inheritance:["KRMN"],configuration:{},createdAt:"2026-05-15T11:29:13.657954",updatedAt:"2026-05-15T11:29:13.657954",createdBy:"lokesh.choraria@techolution.com",updatedBy:"lokesh.choraria@techolution.com",is_user_accepted_risk:!1,has_accepted_risk:"false",user_accepted_risk_at:null,variant_priority:null,isOverridden:!1}],priority:1}]},status:"success",message:"Scope details fetched Successfully"},console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(o=e.data,console.log("rulesData==",o),i=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Object.entries(o).filter(function(e){var t=e[0],r=e[1];return!i.has(t)&&Array.isArray(r)}),l=a.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,r;return null!==(r=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==r?r:[]}))}),s=l.flatMap(function(e){return Array.from(e)}),c=s.reduce(function(e,t){var r;return e[t]=(null!==(r=e[t])&&void 0!==r?r:0)+1,e},{}),p=new Set(Object.entries(c).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),m=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&p.has(e.link_id)})})})})},v=a.map(function(e,t){var r,n=e[0],o=e[1],i=ze.find(function(e){return e.tier_name===n});return{id:null!==(r=null==i?void 0:i.tier_id)&&void 0!==r?r:String(t+1),name:n.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:m(o)}}),(f=u.getState().createdVariantInfo)&&f.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),y=new Set(f.map(function(e){return h[e.tierName]}).filter(Boolean)),g=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||y.has(e.id)})}),re(g),(T=null===(S=null===(_=null===(b=f[0])||void 0===b?void 0:b.variants)||void 0===_?void 0:_[0])||void 0===S?void 0:S.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(T,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return oe()},1e4)},500):oe()):re(v),[3,5]):(re([]),[2]);case 3:return w=t.sent(),console.error("Failed to fetch rule details",w),404!==(null==w?void 0:w.status)&&Se((null==w?void 0:w.message)||"Failed to load rules. Please try again."),re([]),[3,5];case 4:return n||we(!1),[7];case 5:return[2]}})})},nt=ee?_((null==te?void 0:te.data)||null,ee):null,ot=nt?{ruleSetId:nt.id,ruleSetName:nt.name,ruleSetDesc:"",ruleCount:null===(k=null==nt?void 0:nt.metrics)||void 0===k?void 0:k.learningsCount}:void 0,it=function(e){if(!e)return i("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var t=null==ne?void 0:ne.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return n("p",{children:["Are you sure you want to delete"," ",i("span",r({className:S.semibold},{children:null==t?void 0:t.ruleTitle}))," rule? This action cannot be undone."]})};return n(o,ot?{children:[i(y,{ref:ae}),i("div",r({className:S.container},{children:Te?i(h,{}):_e?i(T,{errorMessage:_e,onRetry:rt}):i(g,{onAddRule:tt,onDeleteRule:function(e){Ne(e)},onEditRule:function(e,t){de(e),me(t||null),fe(e.variants||null),ye(null),Ee(!0),ue(!0)},onEditVariant:function(e,t,r,n){var o,i,a,l,s=null!==(a=null===(i=null===(o=null==ne?void 0:ne.find(function(e){return e.name===r}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==a?a:null==ne?void 0:ne.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(l=s.variants)||void 0===l?void 0:l.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;de(s),me(r||null),fe(s.variants||null),ye(c),ue(!0),"resolve_gaps"===n&&He(!0)}},onDeleteVariant:function(e,t){We({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,r,n,o,a,l,s;return t(this,function(t){switch(t.label){case 0:if(!ee)return[2];Re(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ee)];case 2:return e=t.sent(),r=window.URL.createObjectURL(e),(n=document.createElement("a")).href=r,o=(null==ot?void 0:ot.ruleSetName)?"".concat(ot.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ee,".csv"),n.download=o,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(r),null===(l=ae.current)||void 0===l||l.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:i(w,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return a=t.sent(),console.error("Export error:",a),null===(s=ae.current)||void 0===s||s.show({severity:"error",sticky:!1,className:S.errorToast,content:i(b,{message:a.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Re(!1),[7];case 5:return[2]}})})},isExporting:Ce,onToggleSuccess:function(){return rt(!0)},onReorderRules:function(r,n,o,a,l){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,f(r,n,o,a,l)];case 1:return t.sent(),rt(!0),null===(s=ae.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:i(w,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),rt(!0),null===(u=ae.current)||void 0===u||u.show({severity:"error",sticky:!1,className:S.errorToast,content:i(b,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:Je,onCopyToTier:function(e,t,r,n,o){var i,a,l=null===(a=null===(i=null==ne?void 0:ne.find(function(e){return e.name===n}))||void 0===i?void 0:i.rules)||void 0===a?void 0:a.find(function(e){return e.ruleId===t});if(l){var s=["Add a new learning with the following details:","- Rule Title: ".concat(r),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");ke(s),Xe(l),Ze(n),et(o),de(null),me(null),fe(null),ye(null),ue(!0)}}})})),se&&i(C,{children:i(R,{app_integration_id:Z})}),i(I,{isOpen:!!Le,title:G,description:it(Le),warning:q,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,r,n,o,a;return t(this,function(t){switch(t.label){case 0:if(!Le)return[2];Ae(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(Le)];case 2:return t.sent(),Ne(null),null===(r=ae.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:i(w,{message:E})}),rt(),Y&&Y(!1,ee||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(n=ae.current)||void 0===n||n.show({severity:"error",sticky:!1,className:S.errorToast,content:i(b,{message:(null===(a=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===a?void 0:a.detail)||B})}),[3,5];case 4:return Ae(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ne(null)},isLoading:De}),i(I,{isOpen:!!Ue,title:G,description:"variantDeletion"===Ve?i("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):it((null==Ue?void 0:Ue.ruleId)||null),warning:"ruleDeletion"===Ve?q:z,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,r,n,o,a;return t(this,function(t){switch(t.label){case 0:if(!Ue)return[2];Ke(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ve?[3,3]:[4,v(Ue.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,m(Ue.variantId)];case 4:t.sent(),t.label=5;case 5:return We(null),null===(r=ae.current)||void 0===r||r.show({severity:"success",sticky:!1,life:3e3,className:S.successToast,content:i(w,{message:"ruleDeletion"===Ve?E:V})}),rt(),Y&&Y(!1,ee||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(n=ae.current)||void 0===n||n.show({severity:"error",sticky:!1,className:S.errorToast,content:i(b,{message:(null===(a=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===a?void 0:a.detail)||("ruleDeletion"===Ve?B:W)})}),[3,8];case 7:return Ke(!1),[7];case 8:return[2]}})})},onCancel:function(){return We(null)},isLoading:Ge})]}:{children:[i(c,{onCreate:tt,title:L,desc:O,button:A}),se&&i(C,{children:i(R,{app_integration_id:Z})})]})};export{j as default};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as n}from"tslib";import{jsxs as r,Fragment as o,jsx as i}from"react/jsx-runtime";import{useRef as l,useState as a,useEffect as s}from"react";import{useLearningTemplateStore as u}from"../store/useLearningTemplateStore.js";import c from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as d,exportRuleSet as p,deleteRule as m,deleteQuestion as f,alterQuestionPriority as v}from"../apis/scopeApis.js";import g from"../components/RuleContentSkeleton.js";import{Toast as h}from"primereact/toast";import y from"./ContentLogic.js";import T from"../components/ErrorStateDisplay.js";import w from"../shared/SuccessToastContent.js";import S from"../shared/ErrorToastContent.js";import{findNodeById as C}from"../utils/treeUtils.js";import b from"../styles/LearningContent.module.css.js";import I from"../components/ConfirmationModal.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as R}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import j from"../../IL-OTJ/ValueTypeWrappers/TeachMeWrapper.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useAuthStore.js";import"../store/useConfigStore.js";import"../store/useEnvStore.js";var O=function(O){var _,L=O.noRulesTitle,k=void 0===L?"No rules have been added !":L,x=O.noRulesDesc,M=void 0===x?"Start by adding rules that should apply across all stations.":x,D=O.noRulesButtonText,N=void 0===D?"Create New Rule":D,E=O.deleteRuleSuccessMessage,F=void 0===E?"Rule deleted successfully!":E,V=O.deleteVariantSuccessMessage,A=void 0===V?"Variant deleted successfully!":V,J=O.deleteRuleErrorMessage,U=void 0===J?"Failed to delete rule. Please try again.":J,B=O.deleteVariantErrorMessage,P=void 0===B?"Failed to delete variant. Please try again.":B,W=O.deleteModalTitle,G=void 0===W?"Delete":W,q=O.deleteRuleModalWarning,H=void 0===q?"This will permanently delete the rule configuration.":q,z=O.deleteVariantModalWarning,K=void 0===z?"This will permanently delete the variant configuration.":z,Q=O.deleteConfirmText,X=void 0===Q?"Delete":Q,Y=O.onRefreshRuleSets,Z=O.app_integration_id,$=O.token,ee=u(function(e){return e.selectedRuleSetId}),te=u(function(e){return e.scopeTreeData}),ne=u(function(e){return e.sidebarTab}),re=u(function(e){return e.setInitialRules}),oe=u(function(e){return e.currentRules});u(function(e){return e.createdVariantInfo});var ie=u(function(e){return e.resetCreatedVariantInfo}),le=u(function(e){return e.isILModalTriggered}),ae=u(function(e){return e.setIsILModalTriggered}),se=l(null),ue=a(!1),ce=ue[0],de=ue[1],pe=a(null),me=pe[0],fe=pe[1],ve=a(null),ge=ve[0],he=ve[1],ye=a(null),Te=ye[0],we=ye[1],Se=a(null),Ce=Se[0],be=Se[1],Ie=a(!1),Re=Ie[0],je=Ie[1],Oe=a(null),_e=Oe[0],Le=Oe[1],ke=a(!1),xe=ke[0],Me=ke[1],De=a(""),Ne=De[0],Ee=De[1],Fe=a(null),Ve=Fe[0],Ae=Fe[1],Je=a(!1),Ue=Je[0],Be=Je[1],Pe=a(!1),We=Pe[0],Ge=Pe[1],qe=a("ruleDeletion"),He=qe[0],ze=qe[1],Ke=a(null),Qe=Ke[0],Xe=Ke[1],Ye=a(!1),Ze=Ye[0],$e=Ye[1],et=a(!1),tt=et[0],nt=et[1],rt=u.getState().tiers,ot=a(null),it=ot[0],lt=ot[1],at=a(null),st=at[0],ut=at[1],ct=a(null),dt=ct[0],pt=ct[1],mt=function(){fe(null),he(null),de(!0),be(0)},ft=function(){de(!1),ae(!1),fe(null),he(null),we(null),be(null),Ge(!1),nt(!1),vt(),lt(null),ut(null),pt(null),Y&&Y(!1,ee||void 0)};s(function(){vt()},[ee,re]),s(function(){le&&de(!0)},[le]);var vt=function(r){return void 0===r&&(r=!1),e(void 0,void 0,void 0,function(){var e,o,i,l,a,s,c,p,m,f,v,g,h,y,T,w,S,C,b;return t(this,function(t){switch(t.label){case 0:if(!ee)return re([]),[2];r||je(!0),Le(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,d(ee,$)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(o=e.data,console.log("rulesData==",o),i=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),l=Object.entries(o).filter(function(e){var t=e[0],n=e[1];return!i.has(t)&&Array.isArray(n)}),a=l.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),s=a.flatMap(function(e){return Array.from(e)}),c=s.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),p=new Set(Object.entries(c).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),m=function(e){return e.map(function(e){var t;return n(n({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return n(n({},e),{isLinked:!!e.link_id&&p.has(e.link_id)})})})})},f=l.map(function(e,t){var n,r=e[0],o=e[1],i=rt.find(function(e){return e.tier_name===r});return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:r.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"These are the system-wide learnings applied across all stations.":"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:m(o)}}),(v=u.getState().createdVariantInfo)&&v.length>0?(g=Object.fromEntries(l.map(function(e,t){return[e[0],String(t+1)]})),h=new Set(v.map(function(e){return g[e.tierName]}).filter(Boolean)),y=f.map(function(e){return n(n({},e),{isOpen:e.isOpen||h.has(e.id)})}),re(y),(T=null===(b=null===(C=null===(S=v[0])||void 0===S?void 0:S.variants)||void 0===C?void 0:C[0])||void 0===b?void 0:b.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(T,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return ie()},1e4)},500):ie()):re(f),[3,5]):(re([]),[2]);case 3:return w=t.sent(),console.error("Failed to fetch rule details",w),404!==(null==w?void 0:w.status)&&Le((null==w?void 0:w.message)||"Failed to load rules. Please try again."),re([]),[3,5];case 4:return r||je(!1),[7];case 5:return[2]}})})},gt=ee?C((null==te?void 0:te.data)||null,ee):null,ht=gt?{ruleSetId:gt.id,ruleSetName:gt.name,ruleSetDesc:"",ruleCount:null===(_=null==gt?void 0:gt.metrics)||void 0===_?void 0:_.learningsCount}:void 0,yt=function(){if("stations"===ne)return"custom";if(!gt)return"global";switch(gt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Tt=function(e){if(!e)return i("p",{children:"Are you sure you want to delete this rule? This action cannot be undone."});var t=null==oe?void 0:oe.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return r("p",{children:["Are you sure you want to delete"," ",i("span",n({className:b.semibold},{children:null==t?void 0:t.ruleTitle}))," rule? This action cannot be undone."]})};return r(o,ht?{children:[i(h,{ref:se}),i("div",n({className:b.container},{children:Re?i(g,{}):_e?i(T,{errorMessage:_e,onRetry:vt}):i(y,{onAddRule:mt,onDeleteRule:function(e){Ae(e)},onEditRule:function(e,t){fe(e),he(t||null),we(e.variants||null),be(null),Ge(!0),de(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==oe?void 0:oe.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==oe?void 0:oe.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;fe(s),he(n||null),we(s.variants||null),be(c),de(!0),"resolve_gaps"===r&&nt(!0)}},onDeleteVariant:function(e,t){Xe({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ee)return[2];Me(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ee)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,o=(null==ht?void 0:ht.ruleSetName)?"".concat(ht.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ee,".csv"),r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=se.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:i(w,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=se.current)||void 0===s||s.show({severity:"error",sticky:!1,className:b.errorToast,content:i(S,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Me(!1),[7];case 5:return[2]}})})},isExporting:xe,onToggleSuccess:function(){return vt(!0)},onReorderRules:function(n,r,o,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,v(n,r,o,l,a)];case 1:return t.sent(),vt(!0),null===(s=se.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:i(w,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),vt(!0),null===(u=se.current)||void 0===u||u.show({severity:"error",sticky:!1,className:b.errorToast,content:i(S,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:Y,setDeleteConfirmationUsedFor:ze,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==oe?void 0:oe.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Ee(s),lt(a),ut(r),pt(o),fe(null),he(null),we(null),be(null),de(!0)}}})})),ce&&i(R,{children:i(j,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,editingRule:me,editingTier:ge,editingVariants:Te,focusedVariantIndex:Ce,setFocusedVariantIndex:be,triggerAddVariant:We,triggerFixGaps:tt,copiedRule:it,copiedSourceTier:st,copiedTargetTier:dt,initialDraftMessage:Ne,app_integration_id:Z})}),i(I,{isOpen:!!Ve,title:G,description:Tt(Ve),warning:H,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Ve)return[2];Be(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(Ve)];case 2:return t.sent(),Ae(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:i(w,{message:F})}),vt(),Y&&Y(!1,ee||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||U})}),[3,5];case 4:return Be(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ae(null)},isLoading:Ue}),i(I,{isOpen:!!Qe,title:G,description:"variantDeletion"===He?i("span",{children:"Are you sure you want to delete this variant? This action cannot be undone."}):Tt((null==Qe?void 0:Qe.ruleId)||null),warning:"ruleDeletion"===He?H:K,confirmText:X,confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,o,l;return t(this,function(t){switch(t.label){case 0:if(!Qe)return[2];$e(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==He?[3,3]:[4,f(Qe.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,m(Qe.variantId)];case 4:t.sent(),t.label=5;case 5:return Xe(null),null===(n=se.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:i(w,{message:"ruleDeletion"===He?F:A})}),vt(),Y&&Y(!1,ee||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=se.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.errorToast,content:i(S,{message:(null===(l=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===He?U:P)})}),[3,8];case 7:return $e(!1),[7];case 8:return[2]}})})},onCancel:function(){return Xe(null)},isLoading:Ze})]}:{children:[i(c,{onCreate:mt,title:k,desc:M,button:N}),ce&&i(R,{children:i(j,{isOpen:ce,onClose:ft,initialScope:yt(),ruleSet:ht,app_integration_id:Z})})]})};export{O as default};
|
|
2
2
|
//# sourceMappingURL=RuleContent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={publishFeedback:"/instant_learning/save",submitChatFeedback:"/instant_learning/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/scope",renameScope:"/instant_learning/scope",getRulesInRuleSetById:"/instant_learning/rules/scope",createRuleSet:"/instant_learning/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/scope/{ruleSetId}/delete",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteQuestion:"/instant_learning/question/{questionId}",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/learnings/rules/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/toggle_variant",alterRulePriority:"/instant_learning/v2/alterPriority",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation"};export{e as API_ENDPOINTS};
|
|
1
|
+
var e={publishFeedback:"/instant_learning/save",submitChatFeedback:"/instant_learning/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/ilotj/scope",renameScope:"/instant_learning/scope",getRulesInRuleSetById:"/instant_learning/ilotj/rules/scope",createRuleSet:"/instant_learning/ilotj/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/scope/{ruleSetId}/delete",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteQuestion:"/instant_learning/question/{questionId}",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/learnings/rules/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/toggle_variant",alterRulePriority:"/instant_learning/v2/alterPriority",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation"};export{e as API_ENDPOINTS};
|
|
2
2
|
//# sourceMappingURL=apiConfig.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from"tslib";import r from"axios";import{API_ENDPOINTS as n}from"./apiConfig.js";import o from"../store/useAuthStore.js";import s from"../store/useEnvStore.js";var i=function(e){return e.interceptors.request.use(function(e){var t=o.getState().user,r=null==t?void 0:t.accessToken;return r&&(e.headers.Authorization="Bearer ".concat(r)),e}),e},a=function(e,t){return e.interceptors.request.use(function(e){return e.baseURL=t(),e}),e},c=a(i(r.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().audacyBackendUrl||""}),u=a(i(r.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().llmStudioUrl||""}),d=function(e){return a(i(r.create({headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},withCredentials:!0})),function(){return s.getState().llmStudioUrl||""})},l=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.fetchScopes,"/").concat(r),[4,d(o).get(e)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error fetching rule sets:",s),s;case 3:return[2]}})})},
|
|
1
|
+
import{__awaiter as e,__generator as t}from"tslib";import r from"axios";import{API_ENDPOINTS as n}from"./apiConfig.js";import o from"../store/useAuthStore.js";import s from"../store/useEnvStore.js";var i=function(e){return e.interceptors.request.use(function(e){var t=o.getState().user,r=null==t?void 0:t.accessToken;return r&&(e.headers.Authorization="Bearer ".concat(r)),e}),e},a=function(e,t){return e.interceptors.request.use(function(e){return e.baseURL=t(),e}),e},c=a(i(r.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().audacyBackendUrl||""}),u=a(i(r.create({headers:{"Content-Type":"application/json"}})),function(){return s.getState().llmStudioUrl||""}),d=function(e){return a(i(r.create({headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},withCredentials:!0})),function(){return s.getState().llmStudioUrl||""})},l=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.publishFeedback,"?name=").concat(o,"&organizationName=techolution"),[4,u.post(e,r)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error publishing feedback to LLM Studio:",s),s;case 3:return[2]}})})},h=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.submitChatFeedback,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error submitting chat feedback:",e),e;case 3:return[2]}})})},v=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.saveInstantLearningQuestion,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error saving instant learning question:",e),e;case 3:return[2]}})})},f=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.fetchScopes,"/").concat(r),[4,d(o).get(e)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error fetching rule sets:",s),s;case 3:return[2]}})})},p=function(r){return e(void 0,void 0,void 0,function(){var e,o;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.renameScope),[4,u.put(e,r)];case 1:return[2,t.sent().data];case 2:throw o=t.sent(),console.error("Error renaming scope:",o),o;case 3:return[2]}})})},g=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.getRulesInRuleSetById,"/").concat(r),[4,d(o).get(e)];case 1:return[2,t.sent().data];case 2:return s=t.sent(),console.error("Error fetching rules in rule set:",s),[3,3];case 3:return[2]}})})},w=function(r){return e(void 0,void 0,void 0,function(){var e,o;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.getRuleOverrideHistory,"/").concat(r),[4,u.get(e)];case 1:return[2,t.sent().data];case 2:throw o=t.sent(),console.error("Error getting rule override history:",o),o;case 3:return[2]}})})},y=function(r,o){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,d(o).post(n.createRuleSet,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error creating rule set:",e),e;case 3:return[2]}})})},b=function(r,o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e="".concat(n.fetchStationsByKeyword.replace("{keyword}",r),"?allow_existing=").concat(o),[4,c.get(e)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error fetching station name by keyword:",s),s;case 3:return[2]}})})},m=function(r){return e(void 0,void 0,void 0,function(){var e,o;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=n.deleteRuleSet.replace("{ruleSetId}",r),[4,u.delete(e)];case 1:return[2,t.sent().data];case 2:throw o=t.sent(),console.error("Error deleting rule set:",o),o;case 3:return[2]}})})},S=function(r){return e(void 0,void 0,void 0,function(){var e,o;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=n.deleteRule.replace("{ruleId}",r),[4,u.delete(e)];case 1:return[2,t.sent().data];case 2:throw o=t.sent(),console.error("Error deleting rule:",o),o;case 3:return[2]}})})},E=function(r){return e(void 0,void 0,void 0,function(){var e,o;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=n.deleteQuestion.replace("{questionId}",r),[4,u.delete(e)];case 1:return[2,t.sent().data];case 2:throw o=t.sent(),console.error("Error deleting question:",o),o;case 3:return[2]}})})},I=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=n.deleteTier.replace("{scopeId}",r).replace("{tierId}",o),[4,u.delete(e)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error deleting tier:",s),s;case 3:return[2]}})})},R=function(r,o){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.put(n.updateVariant,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error updating variant:",e),e;case 3:return[2]}})})},k=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.inheritScope,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error inheriting scope:",e),e;case 3:return[2]}})})},q=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,c.post(n.updateStation,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error updating station:",e),e;case 3:return[2]}})})},C=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:if(!r)throw new Error("scopeId is required for exporting rule sets");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,u.post(n.exportRuleSet,{scope_id:r},{responseType:"blob"})];case 2:return[2,t.sent().data];case 3:throw e=t.sent(),console.error("Error exporting rule set:",e),e;case 4:return[2]}})})},x=function(r,o,s){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.patch(n.toggleVariant,{variant_ids:r,is_enabled:o})];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error toggling variant status:",e),e;case 3:return[2]}})})},z=function(r,o,s,i,a){return e(void 0,void 0,void 0,function(){var e,c;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e={scopeId:r,tierId:o,move:{movedRuleId:s,prevRuleId:i,nextRuleId:a}},[4,u.put(n.alterRulePriority,e)];case 1:return[2,t.sent().data];case 2:throw c=t.sent(),console.error("Error altering question priority:",c),c;case 3:return[2]}})})},L=function(r,o){return e(void 0,void 0,void 0,function(){var e,s;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=n.fetchRulesByQuestionId.replace("{questionId}",r).replace("{scopeId}",o),[4,u.get(e)];case 1:return[2,t.sent().data];case 2:throw s=t.sent(),console.error("Error fetching rules by question id:",s),s;case 3:return[2]}})})},T=function(r){return void 0===r&&(r={limit:"50",offset:"0"}),e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.retrieveGenreScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error retrieving genre scopes:",e),e;case 3:return[2]}})})},j=function(r){return e(void 0,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.searchScopes,r)];case 1:return[2,t.sent().data];case 2:throw e=t.sent(),console.error("Error searching scopes:",e),e;case 3:return[2]}})})},B=function(r){return e(void 0,void 0,void 0,function(){return t(this,function(e){return[2,new Promise(function(e){setTimeout(function(){e({data:[{stationId:"reetrtdfsds",stationName:"Hot 98.7",stationDesc:"Learnings that apply for Hot 98.7 Station",learningsCount:5},{stationId:"sta-102",stationName:"Smooth Jazz 102.1",stationDesc:"Learnings that apply for Smooth Jazz 102.1 Station",learningsCount:12},{stationId:"sta-103",stationName:"Rock 94",stationDesc:"Learnings that apply for Rock 94 Station",learningsCount:8}]})},500)})]})})},_=function(r){return e(void 0,void 0,void 0,function(){var e,o,s,i;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,u.post(n.sessionValidation,r)];case 1:return e=t.sent(),[2,null!==(i=null===(s=e.data)||void 0===s?void 0:s.is_valid)&&void 0!==i&&i];case 2:return o=t.sent(),console.error("Error validating session:",o),[2,!1];case 3:return[2]}})})};export{z as alterQuestionPriority,c as audacyApi,y as createRuleSet,u as default,E as deleteQuestion,S as deleteRule,m as deleteRuleSet,I as deleteTier,C as exportRuleSet,L as fetchRulesByQuestionId,f as fetchScopes,b as fetchStationsByKeyword,w as getRuleOverrideHistory,g as getRulesInRuleSetById,B as getStationsByScopeId,k as inheritScope,d as llmApiWithToken,l as publishFeedback,p as renameScope,T as retrieveGenreScopes,v as saveInstantLearningQuestion,j as searchScopes,h as submitChatFeedback,x as toggleVariant,q as updateStation,R as updateVariant,_ as validateSession};
|
|
2
2
|
//# sourceMappingURL=scopeApis.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{__assign as e,__spreadArray as n,__awaiter as t,__generator as i}from"tslib";import{jsxs as r,jsx as a,Fragment as o}from"react/jsx-runtime";import l,{useState as s,useRef as u,useEffect as d,useCallback as c,useMemo as v}from"react";import{AlertTriangle as _,Loader as p,Check as f}from"lucide-react";import{Toast as g}from"primereact/toast";import{v4 as m}from"uuid";import{saveInstantLearningQuestion as w,publishFeedback as y,updateVariant as h,fetchRulesByQuestionId as b,submitChatFeedback as T,validateSession as M}from"../apis/scopeApis.js";import A from"../public/ThinkingBulbIcon.gif.js";import{useLearningTemplateStore as I}from"../store/useLearningTemplateStore.js";import S from"../styles/InstantLearningModal.module.css.js";import k from"../../IL-OTJ/ILOTJ.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import{TemplateList as C}from"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{extractAndParseWithProperty as N,parseValidationData as E,extractAndParseResponse as x,extractVariantIds as O}from"../../IL-OTJ/helpers/utils.js";import{useCitations as L}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import"./ToolTip.js";import R from"../store/useAuthStore.js";import"date-fns";import"framer-motion";import"@mui/icons-material/Close";import{useConfigStore as D}from"../store/useConfigStore.js";import"@radix-ui/react-tooltip";import"./StationOnboarding/InputField.js";import"../store/useEnvStore.js";var j=function(){return a("img",{src:A,alt:"Thinking...",width:"20",height:"20"})},V="INITIAL",P="SUCCESS",F="FAILURE",G="IN_PROGRESS",q=function(e){return"string"!=typeof e?"":e.replace(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g,"").replace(/<!--```json[\s\S]*?```-->/g,"").trim()},U=function(e){if(!e)return!1;var n=e.toLowerCase().trim();return"default"===n||"default_variant"===n},J=function(A){var J,H,B,W,K,Y,z=A.isOpen,Q=A.onClose,Z=A.initialScope,$=void 0===Z?"global":Z,X=A.ruleSet,ee=A.editingRule,ne=A.editingTier,te=A.editingVariants,ie=A.focusedVariantIndex,re=A.setFocusedVariantIndex,ae=A.triggerAddVariant,oe=A.triggerFixGaps,le=A.copiedRule,se=A.copiedSourceTier,ue=A.copiedTargetTier,de=A.initialDraftMessage,ce=s({station:$,tiers:["Tier 1"]}),ve=ce[0],_e=ce[1],pe=s(V),fe=pe[0],ge=pe[1],me=s(!1),we=me[0],ye=me[1],he=s("Thank you teacher for teaching me, your rule has been saved successfully."),be=he[0];he[1];var Te=s(""),Me=Te[0],Ae=Te[1],Ie=s(!1),Se=Ie[0],ke=Ie[1],Ce=u(null),Ne=s(!1),Ee=Ne[0],xe=Ne[1],Oe=u(!1),Le=I().tiers,Re=l.useRef(new Set),De=s(null);De[0];var je=De[1],Ve=s(null);Ve[0];var Pe=Ve[1],Fe=s(null);Fe[0];var Ge=Fe[1],qe=u(new Map),Ue=u(""),Je=u(!1),He=s(0),Be=He[0],We=He[1],Ke=s(!1),Ye=Ke[0],ze=Ke[1],Qe=u(null),Ze=u(0),$e=s(null),Xe=$e[0],en=$e[1],nn=s([]),tn=nn[0],rn=nn[1],an=s(null),on=an[0],ln=an[1],sn=s(null),un=sn[0],dn=sn[1],cn=s(!1),vn=cn[0],_n=cn[1],pn=u({}),fn=u([]),gn=u(!1),mn=s(!1),wn=mn[0],yn=mn[1],hn=u(!1),bn=u(new Set),Tn=s(null),Mn=Tn[0],An=Tn[1],In=s(null),Sn=In[0],kn=In[1],Cn=s(null),Nn=Cn[0],En=Cn[1],xn=u(null),On=u(null),Ln=u(null),Rn=u({}),Dn=u([]),jn=u([]),Vn=u({}),Pn=D(),Fn=Pn.configuration,Gn=Pn.ilLabels;d(function(){Mn||kn(null)},[Mn]),d(function(){var e;if(z&&ee){xn.current=ee.ruleId;var n=null===(e=null==te?void 0:te[ie||0])||void 0===e?void 0:e.variantId;En(n||null)}},[z,ee,te,ie]),d(function(){z&&_e(function(n){return e(e({},n),{station:$})})},[z,$]),d(function(){console.log("triggered",Nn),console.log(vt,"structuredAIResponse"),_t(function(n){return Array.isArray(n)?n.map(function(n){return e(e({},n),{is_readOnly:n.variant_id!==Nn&&n.new_variant_id!==Nn})}):n}),yt(function(n){return Array.isArray(n)?n.map(function(n){return e(e({},n),{is_readOnly:n.variant_id!==Nn&&n.new_variant_id!==Nn})}):n})},[Nn]),d(function(){var n;if(!z)return hr(),void(gn.current=!1);if(!gn.current){var t=te,i=t&&t.length>0,r=null!=ee;if(i||r){if((null==ee?void 0:ee.ruleTitle)&&$n(ee.ruleTitle),ne&&(_e(function(n){return e(e({},n),{tiers:[ne]})}),On.current=ne.toLowerCase().replace(/ /g,"_")),i){var a=(null==ne?void 0:ne.toLowerCase().replace(/ /g,"_"))||"tier_1",o=new Map,l=new Map,s=new Map,u=new Map,d=new Map,c=new Map,v=[];t.forEach(function(e,n){u.set(n,e.description||"");var t=e.whenToApply?e.whenToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];d.set(n,t);var i=e.whenNotToApply?e.whenNotToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wnta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];c.set(n,i),v.push(e.variantId||e.variant_id||"")}),o.set(a,u),l.set(a,d),s.set(a,c);var _=null===(n=null==t?void 0:t[ie||0])||void 0===n?void 0:n.variantId,p=t.map(function(e,n){var t,i,r=null===(t=e.configuration)||void 0===t?void 0:t.scheduling_config;return{variant_type:e.variantType||"variant",title:(null==ee?void 0:ee.ruleTitle)||"",rule_description:e.description||"",wta:e.whenToApply||"",wnta:e.whenNotToApply||"",scope:[a],scheduling_config:r||{},variant_id:e.variantId,question_id:(null==ee?void 0:ee.ruleId)||"",tier_id:a.replace("tier_",""),is_readOnly:e.variantId!==_,link_id:e.link_id||"",is_enabled:null===(i=e.is_enabled)||void 0===i||i,is_user_accepted_risk:e.is_user_accepted_risk,has_accepted_risk:e.has_accepted_risk,user_accepted_risk_at:e.user_accepted_risk_at,action:"edit"}});_t(p),_t(p),yt(p),gt(function(e){var n=new Map(e);return n.set(a,JSON.parse(JSON.stringify(p))),n});var f=new Map;t.forEach(function(e,n){var t,i,r,a,o,l,s,u,d,c,v,_,p,g=null===(t=e.configuration)||void 0===t?void 0:t.scheduling_config,m=null!==(a=null!==(i=null==g?void 0:g.order_global_min_separation_seconds)&&void 0!==i?i:null===(r=null==g?void 0:g.order_rules)||void 0===r?void 0:r.global_min_separation_seconds)&&void 0!==a?a:0,w=null!==(s=null!==(o=null==g?void 0:g.advertiser_global_min_separation_seconds)&&void 0!==o?o:null===(l=null==g?void 0:g.advertiser_rules)||void 0===l?void 0:l.global_min_separation_seconds)&&void 0!==s?s:0;f.set(n,{order_rules:{enabled:m>0,global_min_separation_seconds:Math.floor(m/60)},advertiser_rules:{enabled:w>0,global_min_separation_seconds:Math.floor(w/60)},inventory_rules:{respect_inventory_code:null!==(c=null!==(d=null===(u=null==g?void 0:g.inventory_rules)||void 0===u?void 0:u.respect_inventory_code)&&void 0!==d?d:null==g?void 0:g.respect_inventory_code)&&void 0!==c&&c},break_code_rules:{respect_break_code:null!==(p=null!==(_=null===(v=null==g?void 0:g.break_code_rules)||void 0===v?void 0:v.respect_break_code)&&void 0!==_?_:null==g?void 0:g.respect_break_code)&&void 0!==p&&p},is_default_enabled:U(e.variantType||e.variant_type)})}),Hn(new Map([[a,f]])),rt(o),lt(l),dt(s)}else if(r&&ee){var g=ee.ruleDesc;if(g&&rt(new Map([["tier_1",new Map([[0,g]])]])),ee.whenToApply){var m=ee.whenToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,n){return{id:"edit-wta-".concat(n),text:e,reasoning:""}});lt(new Map([["tier_1",new Map([[0,m]])]]))}if(ee.whenNotToApply){var w=ee.whenNotToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,n){return{id:"edit-wnta-".concat(n),text:e,reasoning:""}});dt(new Map([["tier_1",new Map([[0,w]])]]))}}}else if(le&&se&&ue){$n(le.ruleTitle||""),_e(function(n){return e(e({},n),{tiers:[ue]})}),On.current=ue.toLowerCase().replace(/ /g,"_");var y=se.toLowerCase().replace(/ /g,"_"),h=le.variants||[],b=(o=new Map,l=new Map,s=new Map,new Map),T=new Map,M=new Map;h.forEach(function(e,n){b.set(n,e.description||"");var t=e.whenToApply?e.whenToApply.split(" OR ").map(function(e,t){return{id:"copy-wta-".concat(n,"-").concat(t),text:e.trim(),reasoning:""}}):[];T.set(n,t);var i=e.whenNotToApply?e.whenNotToApply.split(" OR ").map(function(e,t){return{id:"copy-wnta-".concat(n,"-").concat(t),text:e.trim(),reasoning:""}}):[];M.set(n,i)}),o.set(y,b),l.set(y,T),s.set(y,M),rt(o),lt(l),dt(s);var A=h.map(function(e,n){var t,i,r=null===(t=e.configuration)||void 0===t?void 0:t.scheduling_config;return{variant_type:e.variantType||"variant",title:le.ruleTitle||"",rule_description:e.description||"",wta:e.whenToApply||"",wnta:e.whenNotToApply||"",scope:[se],scheduling_config:r||{},variant_id:e.variantId,question_id:le.ruleId||"",tier_id:y.replace("tier_",""),is_readOnly:!0,link_id:e.link_id||"",is_enabled:null===(i=e.is_enabled)||void 0===i||i,is_user_accepted_risk:e.is_user_accepted_risk,has_accepted_risk:e.has_accepted_risk,user_accepted_risk_at:e.user_accepted_risk_at,action:"copy"}});_t(A),yt(A),gt(function(e){var n=new Map(e);return n.set(y,JSON.parse(JSON.stringify(A))),n});var I=new Map;h.forEach(function(e,n){var t,i,r,a,o,l,s,u,d,c,v,_,p,f=null===(t=e.configuration)||void 0===t?void 0:t.scheduling_config,g=null!==(a=null!==(i=null==f?void 0:f.order_global_min_separation_seconds)&&void 0!==i?i:null===(r=null==f?void 0:f.order_rules)||void 0===r?void 0:r.global_min_separation_seconds)&&void 0!==a?a:0,m=null!==(s=null!==(o=null==f?void 0:f.advertiser_global_min_separation_seconds)&&void 0!==o?o:null===(l=null==f?void 0:f.advertiser_rules)||void 0===l?void 0:l.global_min_separation_seconds)&&void 0!==s?s:0;I.set(n,{order_rules:{enabled:g>0,global_min_separation_seconds:Math.floor(g/60)},advertiser_rules:{enabled:m>0,global_min_separation_seconds:Math.floor(m/60)},inventory_rules:{respect_inventory_code:null!==(c=null!==(d=null===(u=null==f?void 0:f.inventory_rules)||void 0===u?void 0:u.respect_inventory_code)&&void 0!==d?d:null==f?void 0:f.respect_inventory_code)&&void 0!==c&&c},break_code_rules:{respect_break_code:null!==(p=null!==(_=null===(v=null==f?void 0:f.break_code_rules)||void 0===v?void 0:v.respect_break_code)&&void 0!==_?_:null==f?void 0:f.respect_break_code)&&void 0!==p&&p},is_default_enabled:U(e.variantType||e.variant_type)})}),Hn(new Map([[y,I]]))}}},[z,ee,te,ne,le,se,ue]),d(function(){if(z){if(console.log("[Accordion Init] editingTier:",ne,"focusedVariantIndex:",ie),ne&&_e(function(n){return e(e({},n),{tiers:[ne]})}),vn)return console.log("[Accordion] isAddingNewVariant mode — closing all variant accordions"),void Ct(void 0);if(ae){console.log("[Accordion] triggerAddVariant mode — not opening any variant on RHS"),Ct(void 0);var n=((null==ne?void 0:ne.toLowerCase().replace(/ /g,"_"))||"tier_1").replace(/_/g," ");xt("I want to add a new variant to ".concat(n))}else null!=ie?(console.log("[Accordion] Opening SPECIFIC variant index ".concat(ie," (from VariantCard)")),Ct(ie),$t(function(e){return e+1})):(ee||te&&te.length>0)&&(console.log("[Accordion] Opening DEFAULT/1st variant (index 0) for RuleHeader edit"),Ct(0),$t(function(e){return e+1}))}else Ct(void 0)},[z,ne,ie,ee,te,ae,vn]),d(function(){z&&oe&&ee&&null!==ie&&xt("I want to fix the gaps")},[z,oe,ee,ie]);var qn={order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1},is_default_enabled:!1},Un=s(new Map([["tier_1",new Map([[0,qn]])],["tier_2",new Map([[0,qn]])]])),Jn=Un[0],Hn=Un[1],Bn=s(new Set([])),Wn=Bn[0],Kn=Bn[1],Yn=s("");Yn[0];var zn=Yn[1],Qn=s(""),Zn=Qn[0],$n=Qn[1],Xn=s(new Map([["tier_1",new Map],["tier_2",new Map]])),et=Xn[0],nt=Xn[1],tt=s(new Map([["tier_1",new Map],["tier_2",new Map]])),it=tt[0],rt=tt[1],at=s(new Map([["tier_1",new Map],["tier_2",new Map]])),ot=at[0],lt=at[1],st=s(new Map([["tier_1",new Map],["tier_2",new Map]])),ut=st[0],dt=st[1],ct=s([]),vt=ct[0],_t=ct[1],pt=s(new Map),ft=pt[0],gt=pt[1],mt=s([]),wt=mt[0],yt=mt[1],ht=s(!1),bt=ht[0],Tt=ht[1],Mt=s([]),At=Mt[0],It=Mt[1],St=s(void 0),kt=St[0],Ct=St[1],Nt=s(""),Et=Nt[0],xt=Nt[1],Ot=s(null),Lt=Ot[0],Rt=Ot[1],Dt=s([]),jt=Dt[0],Vt=Dt[1],Pt=s([]),Ft=Pt[0],Gt=Pt[1],qt=s({}),Ut=qt[0],Jt=qt[1],Ht=s(new Map),Bt=Ht[0],Wt=Ht[1],Kt=s(new Set),Yt=Kt[0],zt=Kt[1],Qt=s(0),Zt=Qt[0],$t=Qt[1],Xt=s({ruleTitle:"",ruleDescription:"",scopeData:"",whenToApply:"",whenNotToApply:"",configData:""}),ei=Xt[0],ni=Xt[1],ti=s([]),ii=ti[0],ri=ti[1],ai=s(""),oi=ai[0],li=ai[1],si=s({}),ui=si[0],di=si[1],ci=s(!1),vi=ci[0],_i=ci[1],pi=u(null),fi=u(null),gi=u(-1),mi=u(null);d(function(){jn.current=vt},[vt]),d(function(){var n=new Set,t=console.warn;return console.warn=function(){for(var i,o=[],l=0;l<arguments.length;l++)o[l]=arguments[l];t.apply(void 0,o);var s=o[0];if("string"==typeof s&&s.includes("Failed to parse JSON for property=")){var u=s.match(/warnId="([^"]+)"/),d=null==u?void 0:u[1];if(d&&n.has(d))return;d&&n.add(d),null===(i=mi.current)||void 0===i||i.show({severity:"warn",sticky:!1,life:5e3,className:S.toastWarning,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(_,{className:S.iconWarning}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleWarning)},{children:"Parsing Issue"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageWarning)},{children:"The AI response couldn't be parsed correctly. Please try rephrasing your input or retry."}))]}))})}},function(){console.warn=t}},[]);var wi=s(!1),yi=wi[0],hi=wi[1],bi=s(!1),Ti=bi[0],Mi=bi[1],Ai=s({}),Ii=Ai[0],Si=Ai[1],ki=s(""),Ci=ki[0],Ni=ki[1],Ei=s(!0),xi=Ei[0],Oi=Ei[1],Li=s(!1),Ri=Li[0],Di=Li[1],ji=s(!1),Vi=ji[0],Pi=ji[1],Fi=s(""),Gi=Fi[0],qi=Fi[1],Ui=s(""),Ji=Ui[0],Hi=Ui[1],Bi=s(""),Wi=Bi[0],Ki=Bi[1],Yi=s(null),zi=Yi[0],Qi=Yi[1],Zi=s(null),$i=Zi[0],Xi=Zi[1],er=s(null),nr=er[0],tr=er[1],ir=R.getState().user,rr=L(),ar=rr.dispatch,or=rr.getLatestReasoning;d(function(){console.log("Structured AI Response updated:",vt)},[vt]),d(function(){console.log("isCloseModal AI Response updated:",xi)},[xi]),d(function(){!1===vi?(Mi(!1),qi(""),Hi("")):(ke(!1),Ae(""))},[vi]),d(function(){null!=kt&&te&&!te[kt]&&Qi(null)},[kt,te]),d(function(){if(Ee&&!Oe.current){Oe.current=!0,console.log("UseEffect triggered: Sending save message to chat agent");xt("Save this Learning"),xe(!1),setTimeout(function(){Oe.current=!1,xt("")},2e3)}},[Ee]);var lr=c(function(e,n){tn.some(function(n){return n.id===e})?(Pi(!0),ln(e),dn(n),setTimeout(function(){dn(null),ln(null)},6e3)):console.warn("Variant ID ".concat(e," not found in comparison variants."))},[tn]),sr=v(function(){var e=Vi&&Be>0;return console.log("[Loader Debug] showComparison: ".concat(Vi,", activeRequests: ").concat(Be,", Result: ").concat(e)),e},[Vi,Be]),ur=c(function(n,t,i){var r,a=void 0!==(null===(r=null==i?void 0:i.target)||void 0===r?void 0:r.value)?i.target.value:i;rt(function(e){var i=new Map(e),r=new Map(i.get(n));return r.set(t,a),i.set(n,r),i}),Si(function(i){if(i["ruleDescription-".concat(n,"-").concat(t)]){var r=e({},i);return delete r["ruleDescription-".concat(n,"-").concat(t)],r}return i})},[]),dr=c(function(t,i){lt(function(e){var r=new Map(e),a=new Map(r.get(t)),o=a.get(i)||[];return a.set(i,n(n([],o,!0),[{id:Date.now(),text:"",reasoning:""}],!1)),r.set(t,a),r}),Si(function(n){if(n["whenToApply-".concat(t,"-").concat(i)]){var r=e({},n);return delete r["whenToApply-".concat(t,"-").concat(i)],r}return n})},[]),cr=c(function(e,n,t){lt(function(i){var r=new Map(i),a=new Map(r.get(e)),o=a.get(n)||[];return a.set(n,o.filter(function(e){return e.id!==t})),r.set(e,a),r})},[]),vr=c(function(n,t,i,r){lt(function(a){var o=new Map(a),l=new Map(o.get(n)),s=l.get(t)||[];return l.set(t,s.map(function(n){return String(n.id)===String(i)?e(e({},n),{text:r}):n})),o.set(n,l),o}),Si(function(i){if(i["whenToApply-".concat(n,"-").concat(t)]){var r=e({},i);return delete r["whenToApply-".concat(n,"-").concat(t)],r}return i})},[]),_r=c(function(e,t){dt(function(i){var r=new Map(i),a=new Map(r.get(e)),o=a.get(t)||[];return a.set(t,n(n([],o,!0),[{id:Date.now(),text:"",reasoning:""}],!1)),r.set(e,a),r})},[]),pr=c(function(e,n,t){dt(function(i){var r=new Map(i),a=new Map(r.get(e)),o=a.get(n)||[];return a.set(n,o.filter(function(e){return e.id!==t})),r.set(e,a),r})},[]),fr=c(function(n,t,i,r){dt(function(a){var o=new Map(a),l=new Map(o.get(n)),s=l.get(t)||[];return l.set(t,s.map(function(n){return String(n.id)===String(i)?e(e({},n),{text:r}):n})),o.set(n,l),o})},[]),gr=c(function(e){var n=e.replace(/_/g," ");_n(!0),null==re||re(null),Ct(void 0),xt("I want to add a new variant to ".concat(n))},[]),mr=function(n,t,i){var r="".concat(n,"_").concat(t);console.log("Highlighting ".concat(i," at ").concat(r)),Wt(function(n){var t,a=new Map(n),o=a.get(r)||{};return a.set(r,e(e({},o),((t={})[i]=!0,t))),a}),setTimeout(function(){Wt(function(n){var t,a=new Map(n),o=a.get(r)||{};return a.set(r,e(e({},o),((t={})[i]=!1,t))),a})},1500)},wr=c(function(n,t){_e(function(i){var r;return e(e({},i),((r={})[n]=t,r))}),Si(function(t){if(t[n]){var i=e({},t);return delete i[n],i}return t})},[]),yr=c(function(n,t,i,r){nt(function(e){var r=new Map(e),a=new Map(r.get(n)||new Map),o=a.get(t)||new Set;return o.add(i),a.set(t,o),r.set(n,a),r}),Hn(function(a){var o,l,s,u=new Map(a),d=new Map(u.get(n)||new Map),c=d.get(t)||qn;switch(i){case"order_rules":case"advertiser_rules":s="boolean"==typeof r?e(e({},c),((o={})[i]=e(e({},c[i]),{enabled:r}),o)):"object"==typeof r&&null!==r?e(e({},c),((l={})[i]={enabled:r.enabled,global_min_separation_seconds:r.global_min_separation_seconds},l)):c;break;case"inventory_rules":s=e(e({},c),{inventory_rules:{respect_inventory_code:"boolean"==typeof r?r:r.respect_inventory_code}});break;case"break_code_rules":s=e(e({},c),{break_code_rules:{respect_break_code:"boolean"==typeof r?r:r.respect_break_code}});break;case"is_default_enabled":s=e(e({},c),{is_default_enabled:"boolean"==typeof r?r:!!r});break;default:s=c}return d.set(t,s),u.set(n,d),u})},[]);d(function(){vi&&(Pi(!1),dn(null),ln(null))},[vi]);var hr=c(function(n){var t;if(void 0===n&&(n=!1),n||(ar({type:"RESET"}),pi.current=null,_t([]),It([]),ri([]),di({}),Pi(!1),Re.current.clear()),$n(""),Vt([]),_n(!1),Ue.current="",Ki(""),Xi(null),Gt([]),_e({station:"",tiers:[]}),We(0),ze(!1),tr(null),rt(new Map([["tier_1",new Map],["tier_2",new Map]])),lt(new Map([["tier_1",new Map],["tier_2",new Map]])),dt(new Map([["tier_1",new Map],["tier_2",new Map]])),Hn(new Map([["tier_1",new Map([[0,qn]])],["tier_2",new Map([[0,qn]])]])),nt(new Map([["tier_1",new Map],["tier_2",new Map]])),zn(""),Ct(0),$t(0),_e({station:$,tiers:["Tier 1"]}),n||Jt({}),nt(new Map([["tier_1",new Map],["tier_2",new Map]])),xt(""),ni({ruleTitle:"",ruleDescription:"",scopeData:"",whenToApply:"",whenNotToApply:"",configData:""}),Si({}),Ni(""),Oi(!0),je(null),Pe(null),gt(new Map),yt([]),yn(!1),Ge(null),fi.current=null,Je.current=!1,pn.current={},bn.current.clear(),xn.current=null,On.current=null,En(null),Ae(""),ge(V),ye(!1),ke(!1),xe(!1),en(null),rn([]),ln(null),dn(null),An(null),Tt(!1),Rt(null),qi(""),Hi(""),Mi(!1),Kn(new Set),Oe.current=!1,qe.current.clear(),Ze.current=0,Qe.current=null,Ln.current=null,gi.current=-1,hn.current=!1,gn.current=!1,ee){ee.ruleTitle&&$n(ee.ruleTitle),ne&&(_e(function(n){return e(e({},n),{tiers:[ne]})}),On.current=ne.toLowerCase().replace(/ /g,"_")),xn.current=ee.ruleId;var i=null===(t=null==te?void 0:te[ie||0])||void 0===t?void 0:t.variantId;if(En(i||null),te&&te.length>0){var r=(null==ne?void 0:ne.toLowerCase().replace(/ /g,"_"))||"tier_1",a=new Map,o=new Map,l=new Map,s=new Map,u=new Map,d=new Map;te.forEach(function(e,n){s.set(n,e.description||"");var t=e.whenToApply?e.whenToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];u.set(n,t);var i=e.whenNotToApply?e.whenNotToApply.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wnta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];d.set(n,i)}),a.set(r,s),o.set(r,u),l.set(r,d),rt(a),lt(o),dt(l);var c=te.map(function(e){var n,t,a=null===(n=e.configuration)||void 0===n?void 0:n.scheduling_config;return{variant_type:e.variantType||"variant",title:ee.ruleTitle||"",rule_description:e.description||"",wta:e.whenToApply||"",wnta:e.whenNotToApply||"",scope:[r],scheduling_config:a||{},variant_id:e.variantId,question_id:ee.ruleId||"",tier_id:r.replace("tier_",""),is_readOnly:e.variantId!==i,link_id:e.link_id||"",is_enabled:null===(t=e.is_enabled)||void 0===t||t,is_user_accepted_risk:e.is_user_accepted_risk,has_accepted_risk:e.has_accepted_risk,user_accepted_risk_at:e.user_accepted_risk_at,action:"edit"}});_t(c),yt(c),gt(function(e){var n=new Map(e);return n.set(r,JSON.parse(JSON.stringify(c))),n});var v=new Map;te.forEach(function(e,n){var t,i,r,a,o,l,s,u,d,c,_,p,f,g=null===(t=e.configuration)||void 0===t?void 0:t.scheduling_config,m=null!==(a=null!==(i=null==g?void 0:g.order_global_min_separation_seconds)&&void 0!==i?i:null===(r=null==g?void 0:g.order_rules)||void 0===r?void 0:r.global_min_separation_seconds)&&void 0!==a?a:0,w=null!==(s=null!==(o=null==g?void 0:g.advertiser_global_min_separation_seconds)&&void 0!==o?o:null===(l=null==g?void 0:g.advertiser_rules)||void 0===l?void 0:l.global_min_separation_seconds)&&void 0!==s?s:0;v.set(n,{order_rules:{enabled:m>0,global_min_separation_seconds:Math.floor(m/60)},advertiser_rules:{enabled:w>0,global_min_separation_seconds:Math.floor(w/60)},inventory_rules:{respect_inventory_code:null!==(c=null!==(d=null===(u=null==g?void 0:g.inventory_rules)||void 0===u?void 0:u.respect_inventory_code)&&void 0!==d?d:null==g?void 0:g.respect_inventory_code)&&void 0!==c&&c},break_code_rules:{respect_break_code:null!==(f=null!==(p=null===(_=null==g?void 0:g.break_code_rules)||void 0===_?void 0:_.respect_break_code)&&void 0!==p?p:null==g?void 0:g.respect_break_code)&&void 0!==f&&f},is_default_enabled:U(e.variantType||e.variant_type)})}),Hn(new Map([[r,v]])),Ct(null!=ie?ie:0)}}},[ar,$,ee,ne,te,ie]),br=function(e){if(!e||0===e.length)return"variant 1";var n=e.filter(function(e){var n=e.variant_type||e.variantType||"";return""!==n&&null!==n});return"variant ".concat(n.length+1)},Tr=c(function(){console.log("variantIds",jt),Pi(!0)},[jt]),Mr={"Let me connect the dots for you...":function(e){if("string"==typeof e){var n=e.match(/<!--\s*(\{[^}]*"variant_index"[^}]*\})\s*-->/);if(n)try{var t=JSON.parse(n[1]),i=parseInt(t.variant_index,10);if(!isNaN(i)&&i>0){var r=i-1;gi.current!==r&&(console.log("Opening variant accordion: AI index ".concat(i," → 0-based index ").concat(r)),Ct(r),gi.current=r)}}catch(e){console.error("Failed to parse variant_index from HTML comment:",e)}}},"Crafted Instant Learning with C.A.R.E.":function(t){var i,r=N(t),a=N(t,"general_details");console.log("--- [CARE] Staging Initial Structure ---",r);var o=N(t,"critical_gaps");if(console.log("isCriticalGap",o),ze(!!o),r){if(r.variant_type&&!("is_variant"in r)){var l=null===(i=Ir(r.variant_type||"").toLowerCase().match(/^(default_variant|default|variant)/i))||void 0===i?void 0:i[0];r.variant_type=U(l)?"Default":"variant",r.isDefault=U(l),console.log("parsed.variant_type",r.variant_type)}var s=r.scope&&r.scope.length>0?String(r.scope[0]):null,u=s?Ir(s).toLowerCase().trim().replace(/ /g,"_"):null,d=Boolean(u&&On.current!==u);if(d&&u){var c=On.current;console.log("[Tier Switch Detected]",On.current,"→",u),On.current=u,xn.current=null;var v=(jn.current||[]).findIndex(function(e){return!0===(null==e?void 0:e.is_new_variant)});-1===v&&void 0!==kt&&(v=kt),c&&-1!==v&&(console.log("[Tier Switch] Stripping draft variant at index ".concat(v," from ").concat(c)),rt(function(e){var n=new Map(e),t=new Map(n.get(c)||new Map);return t.delete(v),n.set(c,t),n}),lt(function(e){var n=new Map(e),t=new Map(n.get(c)||new Map);return t.delete(v),n.set(c,t),n}),dt(function(e){var n=new Map(e),t=new Map(n.get(c)||new Map);return t.delete(v),n.set(c,t),n}),Hn(function(e){var n=new Map(e),t=new Map(n.get(c)||new Map);return t.delete(v),n.set(c,t),n}),_t(function(t){if(!Array.isArray(t))return t;var i=n([],t,!0);return i[v]&&(i[v]=e(e({},i[v]),{scope:[u],tier_id:u.replace("tier_","")})),jn.current=i,i})),gi.current=-1;var _=u.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()});_e(function(n){return e(e({},n),{tiers:[_]})})}Rt(r),je({Updated_Fields_Response:r,General_Response:a}),(null==a?void 0:a.variant_id)&&"new_variant_id"===(null==a?void 0:a.variant_id)&&(a.variant_id=null),(null==a?void 0:a.is_interpretation_ready)&&(null==a?void 0:a.question_id)&&ta(a,r,d),(null==a?void 0:a.is_interpretation_ready)&&(null==a?void 0:a.question_id)&&xn.current&&Nn?_t(function(n){if(!Array.isArray(n))return n;var t=n.map(function(n){return(null==n?void 0:n.variant_id)&&n.variant_id===Nn?e(e({},n),r):n}),i=n.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===Nn});return console.log(i,"targetIndexif"),-1!==i&&setTimeout(function(){console.log("targetIndex",i),Ct(i),$t(function(e){return e+1}),gi.current=i},0),t}):(null==a?void 0:a.is_interpretation_ready)&&(null==a?void 0:a.question_id)&&xn.current&&!Nn?_t(function(t){var i;if(Array.isArray(t)){var a=t.findIndex(function(e){return!0===e.is_new_variant});if(-1!==a)setTimeout(function(){Ct(a),$t(function(e){return e+1}),gi.current=a},0),i=t.map(function(n,t){return t===a?e(e(e({},n),r),{is_new_variant:!0,is_variant:!0}):n});else{var o=t.length;setTimeout(function(){Ct(o),$t(function(e){return e+1}),gi.current=o},0),i=n(n([],t,!0),[e(e({},r),{is_new_variant:!0})],!1)}}else setTimeout(function(){Ct(0),$t(function(e){return e+1}),gi.current=0},0),i=[e(e({},r),{is_new_variant:!0})];return jn.current=i,i}):(null==a?void 0:a.is_interpretation_ready)&&(_t([r]),setTimeout(function(){Ct(0),$t(function(e){return e+1}),gi.current=0},0)),void 0!==r.is_user_accepted_risk&&_t(function(t){var i=!(!ee&&!te),a=Array.isArray(t)?n([],t,!0):[];if(i&&0===a.length&&te&&te.length>0&&(a=te.map(function(e,n){var t;return{variant_type:e.variantType||"variant ".concat(n+1),title:(null==ee?void 0:ee.ruleTitle)||"",rule_description:e.description||"",wta:e.whenToApply||"",wnta:e.whenNotToApply||"",is_valid:!0,is_readOnly:e.variantId!==Nn,variant_id:e.variantId,tier_id:(null===(t=e.tier)||void 0===t?void 0:t.tier_id)||"1",is_user_accepted_risk:e.is_user_accepted_risk||!1}})),i){var o=zi||$i,l=a.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===o||(null==e?void 0:e.new_variant_id)&&e.new_variant_id===o||(null==e?void 0:e.id)&&e.id===o});if(-1===l&&void 0!==kt&&(l=kt),-1!==l)return a[l]=e(e({},a[l]),{is_user_accepted_risk:!!r.is_user_accepted_risk}),a}return t})}},"RHS Validation Agent Response":function(t){var i,r,a,o=t;if("string"==typeof t)try{o=JSON.parse(t)}catch(e){o=E(t)}if(Pe(o),console.log("--- [RHS] Updating Staged Logic ---"),console.log("parsed data from RHS Validation",o),o){Rt(function(n){var t=n;if(!t){console.log("⚠️ No staged response found! Constructing fallback from current UI state...");var i=null;if(Array.isArray(vt)){var r=zi||$i,a=-1;!(!ee&&!te)&&r&&(a=vt.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===r||(null==e?void 0:e.new_variant_id)&&e.new_variant_id===r||(null==e?void 0:e.id)&&e.id===r})),-1===a&&void 0!==kt&&(a=kt),-1!==a&&(i=vt[a])}t=i?e({},i):{wta:"",wnta:""}}return e(e({},t),{wta:t.wta,wnta:t.wnta,is_valid:o.is_valid,conflictingConditions:o.conflictingConditions||[],conflictMarkdown:{},conflict_view:o.conflict_view||{}})});var l=(ne||"Tier 1").toLowerCase().replace(/ /g,"_"),s=function(){var e,n=jn.current;if(Array.isArray(n)&&n.length>0){var t,i=n.findIndex(function(e){return!0===(null==e?void 0:e.is_new_variant)});if(-1!==i)return console.log("[RHS] Resolved via is_new_variant flag:",i),i;if(Nn)if(-1!==(t=n.findIndex(function(e){return(null==e?void 0:e.variant_id)===Nn||(null==e?void 0:e.new_variant_id)===Nn})))return t;if(zi)if(-1!==(t=n.findIndex(function(e){return(null==e?void 0:e.variant_id)===zi||(null==e?void 0:e.new_variant_id)===zi})))return t;var r=null!==(e=null==te?void 0:te.length)&&void 0!==e?e:0;if(n.length>r){var a=n.length-1;return console.log("[RHS] Resolved via length diff (new variant appended):",a),a}}var o=void 0!==kt?kt:0;return console.log("[RHS] Fallback index used:",o),o}();if(console.log("Resolved variant index for conflict injection:",s),!1===o.is_valid)((null===(i=o.conflictingConditions)||void 0===i?void 0:i.length)||0)>0&&(Si(function(n){var t=e({},n);return o.conflictingConditions.forEach(function(e){e.condition_wnta&&!e.condition_wta?t["whenNotToApply-".concat(l,"-").concat(s)]=e.reason:t["whenToApply-".concat(l,"-").concat(s)]=e.reason}),t}),Ni("")),o.conflict_view&&((null===(r=o.conflict_view.wta)||void 0===r?void 0:r.length)>0&<(function(t){var i=new Map(t),r=new Map(i.get(l)||new Map),a=n([],r.get(s)||[],!0);return o.conflict_view.wta.forEach(function(n){var t=a.findIndex(function(e){return e.text.trim()===n.value});-1!==t?a[t]=e(e({},a[t]),{conflict:n}):a.push({id:"conflict-wta-".concat(Date.now(),"-").concat(Math.random()),text:n.value,conflict:n})}),r.set(s,a),i.set(l,r),i}),(null===(a=o.conflict_view.wnta)||void 0===a?void 0:a.length)>0&&dt(function(t){var i=new Map(t),r=new Map(i.get(l)||new Map),a=n([],r.get(s)||[],!0);return o.conflict_view.wnta.forEach(function(n){var t=a.findIndex(function(e){return e.text.trim()===n.value});-1!==t?a[t]=e(e({},a[t]),{conflict:n}):a.push({id:"conflict-wnta-".concat(Date.now(),"-").concat(Math.random()),text:n.value,conflict:n})}),r.set(s,a),i.set(l,r),i}));else!0===o.is_valid&&(Si({}),Ni(""),lt(function(n){var t=new Map(n),i=new Map(t.get(l)||new Map),r=i.get(s)||[];return i.set(s,r.map(function(n){return e(e({},n),{conflict:void 0})})),t.set(l,i),t}),dt(function(n){var t=new Map(n),i=new Map(t.get(l)||new Map),r=i.get(s)||[];return i.set(s,r.map(function(n){return e(e({},n),{conflict:void 0})})),t.set(l,i),t}))}},"User Action Execution":function(e){console.log("--- [User Action] Execution ---",e);var n=x(e);(console.log("parsedaction",n),"load"===(null==n?void 0:n.action)&&(null==n?void 0:n.question_id)&&ta(n,null),"save"===(null==n?void 0:n.action)&&(null==n?void 0:n.is_save)&&(Oi(!0),Di(!0)),"discard_rule"===(null==n?void 0:n.action))&&(_t([{variant_id:void 0,rule_description:"",wta:"",wnta:"",variant_type:"variant"}]),yt([]),En(null),Ct(0),$t(0),An(null),yn(!1),_n(!1),Vt([]),xn.current=null,$n(""),tr(null),Hn(new Map([["tier_1",new Map([[0,qn]])],["tier_2",new Map([[0,qn]])]])),rt(new Map([["tier_1",new Map],["tier_2",new Map]])),lt(new Map([["tier_1",new Map],["tier_2",new Map]])),dt(new Map([["tier_1",new Map],["tier_2",new Map]])))},"Validation Agent Response":function(t){var i,r;if(console.log("--- [Validation Agent] Committing Staged Data to UI ---"),console.log("raw data from Validation Agent",t,typeof t),"string"==typeof t){var a=t.match(/<!--\s*```json\s+property="rule_validation_card"\s+([\s\S]*?)```\s*-->/i);if(a&&a[1])try{var o=JSON.parse(a[1].trim()),l=null===(r=null===(i=null==o?void 0:o.validated_rules)||void 0===i?void 0:i[0])||void 0===r?void 0:r.rule_id;l&&(console.log("Setting default comparison ID:",l),ln(l))}catch(e){console.error("Failed to parse rule_validation_card JSON",e)}}var s=N(t,"critical_gaps");console.log("isCriticalGap",s),ze(!!s);var u="string"==typeof t?x(t):t;console.log("parsed data from Validation Agent",u);var d=O(t);Ge(u);var c=!!(null==u?void 0:u.is_variant),v=void 0===(null==u?void 0:u.close_modal)||!!(null==u?void 0:u.close_modal),_=void 0!==(null==u?void 0:u.is_save)&&!!(null==u?void 0:u.is_save);Oi(v),Di(_);var p=null==u?void 0:u.action,f="string"==typeof(null==u?void 0:u.edit_variant_id)&&u.edit_variant_id.trim()?u.edit_variant_id:"string"==typeof(null==u?void 0:u.set_variant_id)&&u.set_variant_id.trim()?u.set_variant_id:null,g="variant"===p&&c;if((null==u?void 0:u.edit_variant_id)&&!g&&Qi(u.edit_variant_id),"edit"!==p&&"edit_current_rule"!==p||!f||Xi(f),g&&(Qi(null),Xi(null)),"discard"===p)return console.log("Action 'discard' received: Resetting UI state but preserving chat."),gn.current=!0,hr(!0),_t([]),pi.current=null,void(fi.current=null);Ki(p);var m=null==u?void 0:u.new_variant_id,w="edit"===(null==u?void 0:u.action)&&(null==u?void 0:u.set_variant_id)&&!te;(null==u?void 0:u.is_valid)?(Si({}),Rt(function(t){var i,r,a,o,l,s,d,c,v,_,p,g;if(console.log("⏮️ PREVIOUS Staged Response:",t),!t)return console.warn("⚠️ No previous staged response found"),t;var m=function(e,n){return Object.prototype.hasOwnProperty.call(e||{},n)},w=e(e({},t),u);Array.isArray(null===(i=null==u?void 0:u.condition_result)||void 0===i?void 0:i.when_to_apply)?w.wta=u.condition_result.when_to_apply.filter(function(e){return e&&"none"!==e.toLowerCase()}).join(" OR "):m(u,"wta")&&void 0!==(null==u?void 0:u.wta)&&(w.wta=null!==(r=null==u?void 0:u.wta)&&void 0!==r?r:""),Array.isArray(null===(a=null==u?void 0:u.condition_result)||void 0===a?void 0:a.when_not_to_apply)?w.wnta=u.condition_result.when_not_to_apply.filter(function(e){return e&&"none"!==e.toLowerCase()}).join(" OR "):m(u,"wnta")&&void 0!==(null==u?void 0:u.wnta)&&(w.wnta=null!==(o=null==u?void 0:u.wnta)&&void 0!==o?o:""),console.log("finalData",w),console.log("checking parsed here :",u);var y,h=f;if(Array.isArray(vt)&&h&&(y=h,vt.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===y||(null==e?void 0:e.new_variant_id)&&e.new_variant_id===y||(null==e?void 0:e.id)&&e.id===y})),"edit"!==(null==u?void 0:u.action)||!ee&&!te)return w;console.log("inside edit flow merge");var b=te||[],T=f,M=T?b.findIndex(function(e){return e.variantId===T||e.variant_id&&e.variant_id===T||e.id&&e.id===T}):-1;if(-1===M&&(null==u?void 0:u.set_variant_id)&&(M=b.findIndex(function(e){return e.variantId===u.set_variant_id||e.variant_id&&e.variant_id===u.set_variant_id||e.id&&e.id===u.set_variant_id})),-1===M&&T&&Array.isArray(vt)&&(M=vt.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===T||(null==e?void 0:e.new_variant_id)&&e.new_variant_id===T||(null==e?void 0:e.id)&&e.id===T})),-1!==M){var A,I,S,k=b[M]||(null==vt?void 0:vt[M]),C=(null==k?void 0:k.tier_id)||(null==k?void 0:k.tierId)||"1",N=(null==ne?void 0:ne.toLowerCase().replace(/ /g,"_"))||"tier_".concat(C);if(gi.current!==M&&(Ct(M),gi.current=M),Array.isArray(null===(l=u.condition_result)||void 0===l?void 0:l.when_to_apply)?A=u.condition_result.when_to_apply.filter(function(e){return e&&"none"!==e.toLowerCase()}).join("\n"):m(u,"wta")&&void 0!==(null==u?void 0:u.wta)?A=null!==(s=null==u?void 0:u.wta)&&void 0!==s?s:"":m(t,"wta")&&void 0!==(null==t?void 0:t.wta)&&(A=null!==(d=null==t?void 0:t.wta)&&void 0!==d?d:""),Array.isArray(null===(c=u.condition_result)||void 0===c?void 0:c.when_not_to_apply)?I=u.condition_result.when_not_to_apply.filter(function(e){return e&&"none"!==e.toLowerCase()}).join("\n"):m(u,"wnta")&&void 0!==(null==u?void 0:u.wnta)?I=null!==(v=null==u?void 0:u.wnta)&&void 0!==v?v:"":m(t,"wnta")&&void 0!==(null==t?void 0:t.wnta)&&(I=null!==(_=null==t?void 0:t.wnta)&&void 0!==_?_:""),void 0!==A){var E=Ir(A);Sr(N,M,A,E,ot,lt,null==u?void 0:u.conflict_view),mr(N,M,"wta")}if(void 0!==I){var x=Ir(I);Sr(N,M,I,x,ut,dt,null==u?void 0:u.conflict_view),mr(N,M,"wnta")}if(m(u,"rule_description")&&void 0!==(null==u?void 0:u.rule_description)?S=null!==(p=null==u?void 0:u.rule_description)&&void 0!==p?p:"":m(t,"rule_description")&&void 0!==(null==t?void 0:t.rule_description)&&(S=null!==(g=null==t?void 0:t.rule_description)&&void 0!==g?g:""),void 0!==S){var O=Ir(S);rt(function(e){var n=new Map(e),t=new Map(n.get(N)||new Map);return t.set(M,O),n.set(N,t),n}),mr(N,M,"ruleDescription")}var L=void 0;m(u,"scheduling_config")&&void 0!==(null==u?void 0:u.scheduling_config)?L=null==u?void 0:u.scheduling_config:m(t,"scheduling_config")&&void 0!==(null==t?void 0:t.scheduling_config)&&(L=null==t?void 0:t.scheduling_config),L&&(Hn(function(e){var n,i,r,a,o,l,s=new Map(e),u=new Map(s.get(N)||new Map);return u.set(M,{order_rules:{enabled:!!(null===(n=L.order_rules)||void 0===n?void 0:n.global_min_separation_seconds),global_min_separation_seconds:Math.floor(((null===(i=L.order_rules)||void 0===i?void 0:i.global_min_separation_seconds)||0)/60)},advertiser_rules:{enabled:!!(null===(r=L.advertiser_rules)||void 0===r?void 0:r.global_min_separation_seconds),global_min_separation_seconds:Math.floor(((null===(a=L.advertiser_rules)||void 0===a?void 0:a.global_min_separation_seconds)||0)/60)},inventory_rules:{respect_inventory_code:!!(null===(o=L.inventory_rules)||void 0===o?void 0:o.respect_inventory_code)},break_code_rules:{respect_break_code:!!(null===(l=L.break_code_rules)||void 0===l?void 0:l.respect_break_code)},is_default_enabled:"Default"===(null==t?void 0:t.variant_type)||"default_variant"===(null==t?void 0:t.variant_type)||"default"===(null==t?void 0:t.variant_type)}),s.set(N,u),s}),mr(N,M,"order_enabled"),mr(N,M,"advertiser_enabled"),mr(N,M,"respect_inventory_code"),mr(N,M,"respect_break_code")),_t(function(t){if(!Array.isArray(t)||M<0||!t[M])return t;var i=n([],t,!0),r=e({},i[M]);return void 0!==A&&(r.wta=A),void 0!==I&&(r.wnta=I),void 0!==S&&(r.rule_description=Ir(S)),L&&(r.scheduling_config=L),console.log("updated variantxxx",r),i[M]=r,i});var R=null==t?void 0:t.variant_type;R&&_t(function(t){var i=Array.isArray(t)?n([],t,!0):[],r=i.findIndex(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===T||(null==e?void 0:e.variant_id)&&e.variant_id===(null==u?void 0:u.set_variant_id)||(null==e?void 0:e.variantId)===T});return-1!==r?i[r]=e(e({},i[r]),{variant_type:R}):i[M]=e(e({},i[M]||{}),{variant_type:R,variant_id:T||(null==u?void 0:u.set_variant_id)}),i})}})):console.warn("⚠️ parsed.is_valid is false, not committing to structuredAIResponse"),w||(c?(Tt(!0),m&&m!==fi.current?(console.log("🚀 New Variant detected (".concat(m,"). Triggering loader.")),Mi(!0),qi("Loading a variant"),console.log("reaching here in new variant flow"),Hi("This may take a moment as we update the rule with the new variant."),fi.current=m):m||console.log("ℹ️ Variant flow detected without specific ID.")):(Tt(!1),fi.current=null),d&&Vt(d))},"Rule comparison results":function(e){try{var n=e;if("string"==typeof e)try{n=JSON.parse(e)}catch(t){n=x(e)||[]}if(!Array.isArray(n)){if(!n||"object"!=typeof n)return void console.error("[Rule comparison results] Data is not an array:",e);n=[n]}var t=n.map(function(e,n){var t,i,r,a,o=null,l=null;if((Array.isArray(e)?e:[e]).forEach(function(e){e&&(e.intent_output&&(o=e.intent_output),e.behaviour_output&&(l=e.behaviour_output))}),"string"==typeof o)try{o=JSON.parse(o)}catch(e){console.error("Failed to parse intent_output",e)}if("string"==typeof l)try{l=JSON.parse(l)}catch(e){console.error("Failed to parse behaviour_output",e)}var s="existing_variant",u="fallback-id-".concat(Math.random()),d=(null==o?void 0:o.documents)||(null==l?void 0:l.documents);if(d){var c=Object.keys(d).find(function(e){return"reference"===d[e].role});c&&(s=c,u="".concat(c,"-").concat(n))}var v="";if((null==o?void 0:o.nodes)&&o.nodes.title){var _=o.nodes.title;(null===(i=null===(t=null==_?void 0:_.comparison_inputs)||void 0===t?void 0:t[s])||void 0===i?void 0:i.content)&&(v=_.comparison_inputs[s].content)}var p="Score";(null==l?void 0:l.final_score)&&(p=l.final_score);var f="Unknown Tier",g=(null===(r=null==d?void 0:d[s])||void 0===r?void 0:r.title)||(null===(a=null==d?void 0:d.existing_variant)||void 0===a?void 0:a.title);return g&&g.includes("|")&&(f=g.split("|")[1].trim()),console.log("Extracted for carousel:",{uniqueId:u,extractedTitle:v,extractedScore:p,extractedScope:f}),{id:u,title:v,similarityScoreText:p,scope:f,intentTreeData:o,behaviorTreeData:l,isLoading:!1}});rn(t)}catch(e){console.error("[Rule comparison results] Critical Handler Error:",e)}}},Ar=function(e){var n=Array.isArray(e)?e.join(" "):String(e||""),t=null==n?void 0:n.match(/<ai_reasoning>([\s\S]*?)<\/ai_reasoning>/);return t?t[1]:null},Ir=function(e){return"string"!=typeof e?"":e.replace(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g,"").replace(/<!--```json[\s\S]*?```-->/g,"").trim()},Sr=function(t,i,r,a,o,l,s){var u;if(void 0!==r){var d=(o.get(t)||new Map).get(i)||[],c=d.map(function(e){return e.text}).join("\n"),v=(null===(u=d[(null==d?void 0:d.length)-1])||void 0===u?void 0:u.reasoning)||"",_=Ar(r)||"";if(""===r&&d.length>0||a.trim()!==c.trim()||_!==v){var p=""===r?{updatedItems:[],newIds:[]}:function(t,i,r){if(!t.trim())return{updatedItems:n([],i,!0),newIds:[]};var a=t.match(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g)||[],o=t.replace(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g,"").replace(/<!--```json[\s\S]*?```-->/g,""),l=[],s=o.replace(/<conflicting>[\s\S]*?<\/conflicting>/g,function(e){return l.push(e),"__CONFLICT_BLOCK_".concat((null==l?void 0:l.length)-1,"__")}).split(/\s*(?:\r?\n|\\+n)\s*/).map(function(e){return e.trim().replace(/^-\s*/,"")}).filter(Boolean),u=new Map(i.map(function(e){return[e.text,e]})),d=[],c=[],v=Array.isArray(null==r?void 0:r.wta)&&t.includes("wta")?r.wta:Array.isArray(null==r?void 0:r.wnta)?r.wnta:[];return s.forEach(function(n,t){var i=n;i.includes("__CONFLICT_BLOCK_")&&(i=i.replace(/__CONFLICT_BLOCK_(\d+)__/g,function(e,n){return l[parseInt(n)]}));var r=a[t]||"",o=i.replace(/<conflicting>[\s\S]*?<\/conflicting>/g,"").trim(),s=null==v?void 0:v.find(function(e){return e.value===o}),_=u.get(i);if(_)c.push(e(e({},_),{reasoning:r||_.reasoning,conflict:s||_.conflict}));else{var p="new-".concat(Date.now(),"-").concat(t);d.push(p),c.push({id:p,text:i,reasoning:r,conflict:s})}}),{updatedItems:c,newIds:d}}(r,d,s),f=p.updatedItems,g=p.newIds;l(function(e){var n=new Map(e),r=new Map(n.get(t)||new Map);return r.set(i,f),n.set(t,r),n}),(null==g?void 0:g.length)>0&&(zt(function(e){return new Set(n(n([],Array.from(e),!0),g,!0))}),setTimeout(function(){zt(function(e){var n=new Set(e);return g.forEach(function(e){return n.delete(e)}),n})},1500))}}},kr=function(e){return(Array.isArray(e)?e:e?[e]:[]).map(function(e){return String(e).replace(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/,"").trim().replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})})};d(function(){Et&&!Oe.current&&"save this learning"!==Et.toLowerCase()&&(ke(!1),Ae(""),gi.current=null!=kt?kt:-1)},[Et]),d(function(){var t,i,r,a,o,l,s,u,d;if(Dn.current=ii,Array.isArray(vt)&&vt.length>0){var c=oi||"local-".concat(Date.now()),v=["ruleTitle","ruleDescription","whenToApply","whenNotToApply","scopeData","configData"],_={},p=pi.current||[];vt.forEach(function(t,i){var r,a;if(t){t.is_readOnly||(Ze.current=i);var o=i;if((null==t?void 0:t.variant_id)&&te)-1!==(l=te.findIndex(function(e){return e.variantId===t.variant_id}))&&(o=l);else if(zi&&te&&1===vt.length){var l;-1!==(l=te.findIndex(function(e){return e.variantId===zi}))&&(o=l)}var s=null!==(r=p[o])&&void 0!==r?r:p[i],u=null!==(a=t.scope)&&void 0!==a?a:null==s?void 0:s.scope,d=kr(u).map(function(e){return e.toLowerCase().replace(/ /g,"_")}),c=d.length>0?d:fn.current.length>0?fn.current:["tier_1"];c.length>0&&(fn.current=c),console.log("prevTierRef.current",fn.current,"targetTiers",c);var f=Ir(t.title);f&&f!==Ir(null==s?void 0:s.title)&&!t.is_readOnly&&function(e,n,t,i,r,a){var o=Ir(i);o&&o!==r&&(mr(e,n,t),a(o))}("global",0,"ruleTitle",t.title,Zn,$n),c.forEach(function(r){var a,l,s,u,d,c=null!==(a=p[o])&&void 0!==a?a:p[i],f=!c,g=void 0!==t.rule_description&&null!==t.rule_description,m=Ir(t.rule_description),w=(null===(l=it.get(r))||void 0===l?void 0:l.get(o))||"",y=Ir(w);g&&(m!==y||""===m&&""!==w)&&(rt(function(e){var n=new Map(e),i=new Map(n.get(r)||new Map);return i.set(o,t.rule_description),n.set(r,i),n}),mr(r,o,"ruleDescription"));var h=!1===(null==Lt?void 0:Lt.is_valid),b=Ir(t.wta),T=Ir(null==c?void 0:c.wta),M=(null===(s=ot.get(r))||void 0===s?void 0:s.get(o))||[];!(h&&""===b&&M.length>0)&&void 0!==t.wta&&null!==t.wta&&(b!==T||""===b&&M.length>0||0===M.length&&""!==b)&&(Sr(r,o,t.wta,b,ot,lt,null==Lt?void 0:Lt.conflict_view),mr(r,o,"wta"));var A=Ir(t.wnta),I=Ir(null==c?void 0:c.wnta),S=(null===(u=ut.get(r))||void 0===u?void 0:u.get(o))||[];if(!(h&&""===A&&S.length>0)&&void 0!==t.wnta&&null!==t.wnta&&(A!==I||""===A&&S.length>0||0===S.length&&""!==A)&&(Sr(r,o,t.wnta,A,ut,dt,null==Lt?void 0:Lt.conflict_view),mr(r,o,"wnta")),t.scheduling_config||f||t.variant_type||t.variantType){var k=t.scheduling_config||{order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1}},C=null==c?void 0:c.scheduling_config,N=null===(d=Jn.get(r))||void 0===d?void 0:d.get(o),E=t.variant_type||t.variantType,x=E?U(E):void 0,O=JSON.stringify(k)!==JSON.stringify(C),L=void 0!==x&&x!==(null==N?void 0:N.is_default_enabled),R=function(n,t){if(!n)return t;if(!t)return n;var i=e({},n);for(var r in t)t[r]&&"object"==typeof t[r]&&!Array.isArray(t[r])?i[r]=e(e({},i[r]||{}),t[r]):i[r]=t[r];return i};if(Jt(function(e){return R(e,k)}),O||L){Jt(function(e){return R(e,k)});var D=function(e,n,t,i){var r,a,o,l,s=[],u=(i.get(e)||new Map).get(n)||{order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1}};return Math.floor(((null===(r=t.order_rules)||void 0===r?void 0:r.global_min_separation_seconds)||0)/60)!==u.order_rules.global_min_separation_seconds&&s.push("config_order_rules"),Math.floor(((null===(a=t.advertiser_rules)||void 0===a?void 0:a.global_min_separation_seconds)||0)/60)!==u.advertiser_rules.global_min_separation_seconds&&s.push("config_advertiser_rules"),!!(null===(o=t.inventory_rules)||void 0===o?void 0:o.respect_inventory_code)!==u.inventory_rules.respect_inventory_code&&s.push("config_inventory_rules"),!!(null===(l=t.break_code_rules)||void 0===l?void 0:l.respect_break_code)!==u.break_code_rules.respect_break_code&&s.push("config_break_code_rules"),!!t.is_default_enabled!=!!u.is_default_enabled&&s.push("config_is_default_enabled"),s}(r,o,k,Jn);D.forEach(function(e){return mr(r,o,e)}),Kn(function(e){return new Set(e).add("config")}),Hn(function(n){var t,i,a,l,s,u,d=new Map(n),c=new Map(d.get(r)||new Map),v=c.get(o)||qn;return c.set(o,e(e(e(e(e(e({},v),k.order_rules&&{order_rules:{enabled:!!(null===(t=k.order_rules)||void 0===t?void 0:t.global_min_separation_seconds),global_min_separation_seconds:Math.floor(((null===(i=k.order_rules)||void 0===i?void 0:i.global_min_separation_seconds)||0)/60)}}),k.advertiser_rules&&{advertiser_rules:{enabled:!!(null===(a=k.advertiser_rules)||void 0===a?void 0:a.global_min_separation_seconds),global_min_separation_seconds:Math.floor(((null===(l=k.advertiser_rules)||void 0===l?void 0:l.global_min_separation_seconds)||0)/60)}}),k.inventory_rules&&{inventory_rules:{respect_inventory_code:!!(null===(s=k.inventory_rules)||void 0===s?void 0:s.respect_inventory_code)}}),k.break_code_rules&&{break_code_rules:{respect_break_code:!!(null===(u=k.break_code_rules)||void 0===u?void 0:u.respect_break_code)}}),void 0!==x&&{is_default_enabled:x})),d.set(r,c),d}),nt(function(e){var n=new Map(e),t=new Map(n.get(r)||new Map),i=t.get(o)||new Set;return k.order_rules&&i.add("order_rules"),k.advertiser_rules&&i.add("advertiser_rules"),k.inventory_rules&&i.add("inventory_rules"),k.break_code_rules&&i.add("break_code_rules"),void 0!==x&&i.add("is_default_enabled"),t.set(o,i),n.set(r,t),n})}}var j={ruleTitle:t.title,ruleDescription:t.rule_description,whenToApply:t.wta,whenNotToApply:t.wnta,scopeData:t.scope,configData:t.action};t.is_readOnly||v.forEach(function(e){var n=Ar(j[e]),t="ruleTitle"===e||"scopeData"===e?e:"".concat(e,"_").concat(r);n&&(n!==Rn.current[t]&&(Rn.current[t]=n,Vn.current[t]=!0,_[t]={reasoning:n,associatedCitations:[],tier:r,variantIndex:o}))}),t.conflictingConditions&&(Si(function(n){var i=e({},n);return t.conflictingConditions.forEach(function(e){e.condition_wta&&(i["whenToApply-".concat(r,"-").concat(o)]=e.reason),e.condition_wnta&&(i["whenNotToApply-".concat(r,"-").concat(o)]=e.reason)}),i}),Kn(function(e){return new Set(n(n([],Array.from(e),!0),["conditions"],!1))}))})}});var f=-1,g=!(!ee&&!te),m="edit"===Wi||"edit_current_rule"===Wi,w=function(e,n){return(null==e?void 0:e.variant_id)&&e.variant_id===n||(null==e?void 0:e.new_variant_id)&&e.new_variant_id===n||(null==e?void 0:e.id)&&e.id===n},y=function(e,n){if(!n)return-1;var t=e.find(function(e){return w(e,n)});if(!t)return-1;var i=String((null==t?void 0:t.tier_id)||"");if(!i)return e.findIndex(function(e){return w(e,n)});var r=e.filter(function(e){return String((null==e?void 0:e.tier_id)||"")===i}).findIndex(function(e){return w(e,n)});return-1!==r?r:e.findIndex(function(e){return w(e,n)})};if(g)if(fi.current&&bt)-1!==(f=vt.findIndex(function(e){return(null==e?void 0:e.new_variant_id)&&e.new_variant_id===fi.current||(null==e?void 0:e.variant_id)&&e.variant_id===fi.current||(null==e?void 0:e.id)&&e.id===fi.current}))&&(fi.current=null);else if(zi||$i){var h;(h=zi||$i)&&(f=y(vt,h))}else if(ae&&Array.isArray(vt)&&vt.length>0){for(b=vt.length-1;b>=0;b--)if(vt[b]&&!(null===(i=vt[b])||void 0===i?void 0:i.is_readOnly)){f=b;break}}else null==ie||pi.current&&0!==pi.current.length||(f=ie);else if((h=zi||$i||fi.current)&&m&&(f=y(vt,h)),!m&&-1===f&&Array.isArray(vt)&&vt.length>0){for(var b=vt.length-1;b>=0;b--)if(vt[b]&&!(null===(t=vt[b])||void 0===t?void 0:t.is_readOnly)){f=b;break}-1===f&&(f=vt.length-1)}-1!==f&&kt!==f&&(gi.current===f||Je.current&&!m||(console.log("🎯 Setting active variant accordion to index ".concat(f," (").concat(g?"EDIT":"CREATE"," mode)")),Ct(f),gi.current=f));var T=vt[0];if(T){if(T.scope&&JSON.stringify(T.scope)!==JSON.stringify(null===(r=p[0])||void 0===r?void 0:r.scope)&&"copy"!==T.action&&(l=T.scope,s=null===(a=p[0])||void 0===a?void 0:a.scope,u=kr(l),d=s?kr(s):[],_e(function(n){return e(e({},n),{tiers:u})}),u.forEach(function(e){var n=e.trim();d.includes(e)||mr("global",0,"scope_".concat(n))})),T.scope_rule_set&&T.scope_rule_set!==(null===(o=p[0])||void 0===o?void 0:o.scope_rule_set)){var M=T.scope_rule_set.toLowerCase().trim();["global","genre","custom"].includes(M)&&(_e(function(n){return e(e({},n),{station:M})}),mr("global",0,"scope_station"))}T.wtl&&zn(T.wtl)}pi.current=vt.map(function(e){return e?(n=e,"function"==typeof(t=null===globalThis||void 0===globalThis?void 0:globalThis.structuredClone)?t(n):JSON.parse(JSON.stringify(n))):e;var n,t}),Object.keys(_).length>0&&(ar({type:"SAVE_CITATIONS",requestId:c,reasoningMap:_,rawCitations:ii}),function(e){var n=e.requestId,t=e.keys,i=e.newReasoningMap,r=e.getLatestReasoning,a=e.currentCitations;console.group("%c Citation Audit: ".concat(n," "),"background: #5928ed; color: #fff; font-weight: bold;");var o={};t.forEach(function(e){var n=r(e),t=!!i[e],l=t?a:(null==n?void 0:n.associatedCitations)||[];o[e]={Status:t?"NEW ✅":n?"FALLBACK 🔄":"EMPTY ❌",Source:t?"Current Msg":n?"History":"N/A","Reasoning Preview":t?i[e].reasoning:(null==n?void 0:n.reasoning)||"None","Full Citations":l}}),console.table(o),console.groupEnd()}({requestId:c,keys:Object.keys(_),newReasoningMap:_,getLatestReasoning:or,currentCitations:ii}),ni(function(n){var t=e({},n),i=!1;return Object.keys(_).forEach(function(e){var n=_[e];n.reasoning&&t[e]!==n.reasoning&&(t[e]=n.reasoning,i=!0),n.associatedCitations}),i?t:n}))}},[vt,ii,oi]),d(function(){var t=Object.keys(Vn.current);if(0!==t.length){var i={};t.forEach(function(e){i[e]=n([],ii,!0)}),Vn.current={},di(function(n){return e(e({},n),i)})}},[ii]);var Cr=function(e){return e.map(function(e){var n;return null===(n=e.match(/\d+/))||void 0===n||n[0],e.replace(/\s+/g,"-"),{name:"Custom",parentScopeId:null,scopeRowId:(null==X?void 0:X.ruleSetId)||"",value:{scopeName:(null==X?void 0:X.ruleSetName)||"",scopeId:"Audacy_"+m(),customScopeGroupName:(null==Fn?void 0:Fn.CUSTOM_SCOPE_GROUP_NAME)||"",description:(null==X?void 0:X.ruleSetDesc)||""}}})},Nr=function(e){var n={};return Object.entries(e).forEach(function(e){var t,i=e[0],r=e[1];if("custom_sep_time_for_entities"===i&&r)n.custom_sep_time_for_entities=r;else if("max_priority_override"===i&&r&&void 0!==r.override_priority_code)n.override_priority_code=r.override_priority_code;else if(r&&"object"==typeof r&&(null===(t=Object.keys(r))||void 0===t?void 0:t.length)>0){var a=i.replace(/_rules$/,""),o=["global_min_separation_seconds","respect_inventory_code","respect_break_code","exemption_advertiser_list","exemption_break_code_list","exemption_priority_code_list"];Object.entries(r).forEach(function(e){var t=e[0],r=e[1];if(o.includes(t)&&("product_rules"!==i||"global_min_separation_seconds"!==t)){var l="respect_inventory_code"===t||"respect_break_code"===t?t:"".concat(a,"_").concat(t);n[l]=r}})}else if(void 0!==r&&"object"!=typeof r){if("station_guid"===i||"is_default_enabled"===i)return;n[i]=r}}),{config_structure:{scheduling_config:{respect_break_code:"bool",respect_inventory_code:"bool",order_global_min_separation_seconds:"int",order_exemption_advertiser_list:"array",order_exemption_break_code_list:"array",order_exemption_priority_code_list:"array",advertiser_global_min_separation_seconds:"int",advertiser_exemption_advertiser_list:"array",advertiser_exemption_break_code_list:"array",advertiser_exemption_priority_code_list:"array",product_exemption_advertiser_list:"array",product_exemption_break_code_list:"array",product_exemption_priority_code_list:"array",break_code_exemption_advertiser_list:"array",break_code_exemption_break_code_list:"array",break_code_exemption_priority_code_list:"array",inventory_exemption_advertiser_list:"array",inventory_exemption_break_code_list:"array",inventory_exemption_priority_code_list:"array",override_priority_code:"str",custom_sep_time_for_entities:"object"}},config_data:{scheduling_config:n}}},Er=function(n,t,i,r){void 0===r&&(r=0);var a=e({},t||{});return n.forEach(function(n,o){var l=n.get(r);l&&l.forEach(function(n){var l,s=t[n]||{},u=i.get(o),d=null==u?void 0:u.get(r),c=null==d?void 0:d[n];if("order_rules"===n||"advertiser_rules"===n){var v=null!==(l=null==c?void 0:c.enabled)&&void 0!==l&&l?60*((null==c?void 0:c.global_min_separation_seconds)||0):0;a[n]=e(e({},s),{global_min_separation_seconds:v})}else a[n]="inventory_rules"===n?e(e({},s),{respect_inventory_code:null==c?void 0:c.respect_inventory_code}):"break_code_rules"===n?e(e({},s),{respect_break_code:null==c?void 0:c.respect_break_code}):"is_default_enabled"===n?null!=c&&c:s})}),a},xr=function(e,n,t){void 0===t&&(t="variantType");var i=null==e?void 0:e[n];if(!i)return{label:br(e),isDefault:!1};var r=i[t]||"",a=U(r);return{label:"variant ".concat(n+1),isDefault:a}},Or=function(e,n){var t=U(e);return{label:"variant ".concat(n+1),isDefault:t}},Lr=function(e,n,t){var i;void 0===t&&(t="");var r=null===(i=Jn.get(e))||void 0===i?void 0:i.get(n);return r?r.is_default_enabled?"Default":"Variant":U(t)?"Default":"Variant"},Rr=function(n,o){return void 0===o&&(o=!1),t(void 0,void 0,void 0,function(){var t,l,s,u,d,c,v,p,g,w,h,b,T,M,A,k;return i(this,function(i){switch(i.label){case 0:t=Cr(ve.tiers),l=Ze.current,s=Er(et,Ut,Jn,l),i.label=1;case 1:return i.trys.push([1,3,,4]),ge(G),Ae(""),u=Nr(s),d=m(),c=[],v=[],p=(vt||[])[l]||{},console.log("originalItem check :",p,l),ve.tiers.forEach(function(i){var r,a,o,s,_,f,g,w,h,b,T,M=i.toLowerCase().replace(/ /g,"_");v.push(M);var A=(null===(r=it.get(M))||void 0===r?void 0:r.get(l))||"",I=(null===(a=ot.get(M))||void 0===a?void 0:a.get(l))||[],S=(null===(o=ut.get(M))||void 0===o?void 0:o.get(l))||[],k={status:"approved",metadata:e(e({userName:null!==(s=null==ir?void 0:ir.firstname)&&void 0!==s?s:"",userEmailId:null!==(_=null==ir?void 0:ir.email)&&void 0!==_?_:"",llm:Fn.MODEL,isVariantFlow:!0},u&&{config:e({master_name:Fn.CONFIG_MASTER_NAME},u)}),{datasource:{type:"link",ref:"www.something.com",tag:"something"},variant:{tierLinkId:d,variant:Ir(A),conditions_whentoapply:I.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),conditions_whennottoapply:S.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),referenceVariantID:null,referenceVariantIDVersion:null,scope:t[0]||{name:Fn.SCOPE_NAME,parentScopeId:null,scopeRowId:(null==X?void 0:X.ruleSetId)||"",value:{scopeName:(null==X?void 0:X.ruleSetName)||"",scopeId:"Audacy_"+m(),customScopeGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,description:(null==X?void 0:X.ruleSetDesc)||""}},overriden:!1,isDefault:null===(w=null===(g=null===(f=Jn.get(M))||void 0===f?void 0:f.get(l))||void 0===g?void 0:g.is_default_enabled)||void 0===w||w,tier:{name:i.split(" ").join("").toLowerCase(),tierGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,tierPriority:parseInt(i.split(" ")[1]||"1"),tier_id:(null===(h=Le.find(function(e){return e.tier_name.toLowerCase().replace(/ /g,"_")===M||e.tier_name.toLowerCase()===M.replace(/_/g,"")}))||void 0===h?void 0:h.tier_id)||""},topic:{id:null,value:"".concat(ve.station||$,"RuleSet"),description:null},categories:[{id:null,value:Fn.CATEGORY,description:Fn.CATEGORY}],originalQuestion:Zn,questionId:n.get(M)||null,variantType:Lr(M,l,p.variant_type||p.variantType),parameterizedQuestion:null,created_at:(new Date).toISOString(),created_by:null!==(b=null==ir?void 0:ir.email)&&void 0!==b?b:"",instantLearningType:Fn.INSTANT_LEARNING_TYPE,appliedTagsIL:[],tagMappingInfoIL:{},is_user_accepted_risk:!!(null!==(T=null==p?void 0:p.is_user_accepted_risk)&&void 0!==T?T:null==Lt?void 0:Lt.is_user_accepted_risk)},isAgentsFeedback:!0})};c.push(y(k,Fn.ASSISTANT_NAME))}),[4,Promise.all(c)];case 2:return g=i.sent(),xe(!1),console.log("✅ All feedback published:",g),ge(P),ye(!0),w=new Map,g.forEach(function(e,n){var t,i,r=v[n],a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.variant_id)&&e.data.variant_id||(null==e?void 0:e.id)||(null==e?void 0:e.variant_id)&&e.variant_id;if(a||"string"!=typeof(null==e?void 0:e.data)||(a=e.data),a&&"string"==typeof a){var o=w.get(r)||[];o.push({id:a,action:"new"}),w.set(r,o)}}),I.getState().setCreatedVariantInfo(Array.from(w.entries()).map(function(e){return{tierName:e[0],variants:e[1]}})),null===(M=mi.current)||void 0===M||M.show({severity:"success",sticky:!1,life:6e3,className:S.toastSuccess,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(f,{className:S.iconSuccess}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleSuccess)},{children:"Success"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageSuccess)},{children:"Learning saved successfully!"}))]}))}),Ce.current=setTimeout(function(){xi||o?(console.log("Closing modal after save success",{isCloseModal:xi,forceClose:o}),ea()):hr(!0)},3e3),[3,4];case 3:return h=i.sent(),console.error("❌ Error publishing feedback:",h),xe(!1),ge(F),ke(!0),b=(null===(A=null==h?void 0:h.response)||void 0===A?void 0:A.data)||{},console.log("errorData: ",b),(T="Variant already exists"===(null==b?void 0:b.message))||409===(null==h?void 0:h.status)?Ae('Looks like a similar rule already exists with the same conditions. You can update the description or conditions to make it unique, or discard this learning. <br/> How would you like to proceed?\n <br/><button class="clickable-button" data-value="Discard learning">Discard learning</button>\n <br/><button class="clickable-button" data-value="Continue editing learning">Continue editing learning</button>\n <br/><button class="clickable-button" id="typeYourAnswer">Or, type your response</button>'):Ae(((null==b?void 0:b.message)||(null==b?void 0:b.detail)||"Error Occurred while saving the rule.")+'Please try again.<br/><button class="clickable-button" data-value="Save this Learning">Retry</button>'),null===(k=mi.current)||void 0===k||k.show({severity:"error",sticky:!1,className:S.toastError,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(_,{className:S.iconError}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleError)},{children:"Error"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageError)},{children:T||409===(null==h?void 0:h.status)?"Similar rule already exists. Please update and try again.":(null==b?void 0:b.message)||(null==b?void 0:b.detail)||"Something went wrong while saving the learning!"}))]}))}),[3,4];case 4:return[2]}})})},Dr=function(){return t(void 0,void 0,void 0,function(){var t,o,l,s,u,d,c,v,p,g,w,b,T,M,A,k,C,N,E,x,O,L,R,D,j,V;return i(this,function(i){switch(i.label){case 0:t=I.getState().tiers,o=Er(et,Ut,Jn),l=Nr(o),s=Ze.current,u=(vt||[])[s]||{},d=(null==Lt?void 0:Lt.variant_type)||u.variant_type||"",i.label=1;case 1:for(i.trys.push([1,3,,4]),ge(G),Ae(""),v=(c=te||[]).length>0?null===(O=c.find(function(e){return(null==e?void 0:e.link_id)&&""!==e.link_id.trim()}))||void 0===O?void 0:O.link_id:null,p=(null===(L=ve.tiers[0])||void 0===L?void 0:L.toLowerCase().replace(/ /g,"_"))||"tier_1",g=(null===(R=it.get(p))||void 0===R?void 0:R.size)||c.length,w=n([],c,!0),b=c.length;b<g;b++)w.push({isNewVariant:!0,variantId:m()});return T=[],M=[],A=Cr(ve.tiers),ve.tiers.forEach(function(n){var i=n.toLowerCase().replace(/ /g,"_"),r=t.find(function(e){return e.tier_name.toLowerCase().replace(/ /g,"_")===i||e.tier_name.toLowerCase()===i.replace(/_/g,"")}),a=it.get(i),o=ot.get(i),s=ut.get(i);w.forEach(function(t,c){var _,p,f,g,w,b,I,S,k,C,N,E,x,O,L,R,D,j,V,P,F,G,J,H,B,W,K,Y,z=(null==a?void 0:a.get(c))||t.description||"",Q=(null==o?void 0:o.get(c))||[],Z=(null==s?void 0:s.get(c))||[];if(t.isNewVariant){M.push({tierKey:i,payloadType:"new"});var $=Er(et,Ut,Jn,c),ne=Nr($);console.log("variant in save edit add part :",t,u);var te={status:"approved",metadata:e(e({userName:null!==(_=null==ir?void 0:ir.firstname)&&void 0!==_?_:"",userEmailId:null!==(p=null==ir?void 0:ir.email)&&void 0!==p?p:"",llm:Fn.MODEL,isVariantFlow:!0},ne&&{config:e({master_name:Fn.CONFIG_MASTER_NAME},ne)}),{datasource:{type:"link",ref:"www.something.com",tag:"something"},variant:{tierLinkId:v||m(),variant:Ir(z),conditions_whentoapply:Q.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),conditions_whennottoapply:Z.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),referenceVariantID:null,referenceVariantIDVersion:null,scope:A[0]||{name:Fn.SCOPE_NAME,parentScopeId:null,scopeRowId:(null==X?void 0:X.ruleSetId)||"",value:{scopeName:(null==X?void 0:X.ruleSetName)||"",scopeId:"Audacy_"+m(),customScopeGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,description:(null==X?void 0:X.ruleSetDesc)||""}},overriden:!1,isDefault:null!==(w=null===(g=null===(f=Jn.get(i))||void 0===f?void 0:f.get(c))||void 0===g?void 0:g.is_default_enabled)&&void 0!==w?w:U(t.variantType||t.variant_type||(0===c?"Default":"variant")),tier:{name:n.split(" ").join("").toLowerCase(),tierGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,tierPriority:parseInt(n.split(" ")[1]||"1")},topic:{id:null,value:"".concat(ve.station,"RuleSet"),description:null},categories:[{id:null,value:Fn.CATEGORY,description:Fn.CATEGORY}],originalQuestion:Zn,questionId:null==ee?void 0:ee.ruleId,variantType:Lr(i,c,u.variant_type||""),parameterizedQuestion:null,created_at:(new Date).toISOString(),created_by:null!==(b=null==ir?void 0:ir.email)&&void 0!==b?b:"",instantLearningType:Fn.INSTANT_LEARNING_TYPE,appliedTagsIL:[],tagMappingInfoIL:{},is_user_accepted_risk:!!(null!==(S=null===(I=(vt||[])[c])||void 0===I?void 0:I.is_user_accepted_risk)&&void 0!==S?S:null==Lt?void 0:Lt.is_user_accepted_risk)},isAgentsFeedback:!0})};console.log("payload (publish new variant)",te),T.push(y(te,Fn.ASSISTANT_NAME))}else{M.push({tierKey:i,payloadType:"existing",existingId:t.variantId});var ie=t.variantId===zi,re=Lr(i,c,ie?d||t.variantType||"":t.variantType||"");console.log("isThisVariantBeingEdited variantTypeToUse :",re,ie,t,zi);var ae={variantId:t.variantId,ruleDesc:(null==X?void 0:X.ruleSetDesc)||"",whenToApply:Q.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),whenNotToApply:Z.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),isDefault:null!==(N=null===(C=null===(k=Jn.get(i))||void 0===k?void 0:k.get(c))||void 0===C?void 0:C.is_default_enabled)&&void 0!==N?N:U(t.variantType||t.variant_type||(0===c?"Default":"variant")),tier:{tier_id:(null==r?void 0:r.tier_id)||"",tier_name:(null==r?void 0:r.tier_name)||n,tier_priority:null!==(E=null==r?void 0:r.tier_priority)&&void 0!==E?E:null},scope_id:(null==X?void 0:X.ruleSetId)||"",description:Ir(z)||"",topic:"".concat(ve.station,"RuleSet"),configuration:(null==l?void 0:l.config_data)||{},tierLinkId:null!=v?v:null,variantType:re,is_user_accepted_risk:!!(null!==(O=null===(x=(vt||[])[c])||void 0===x?void 0:x.is_user_accepted_risk)&&void 0!==O?O:null==t?void 0:t.is_user_accepted_risk),is_enabled:t.is_enabled},oe=(ft.get(i)||[]).find(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===t.variantId}),le=!0;if(oe){var se=function(e){var n=(e||"").trim();return(n=q(n)).replace(/\s+/g," ").replace(/(\s*OR\s*)/g," OR ")},ue=se(Zn)===se(oe.title),de=se(z)===se(oe.rule_description),ce=se(ae.whenToApply)===se(oe.wta),_e=se(ae.whenNotToApply)===se(oe.wnta),pe=!!ae.isDefault===U(oe.variant_type),fe=oe.scheduling_config||{},ge=null!==(D=null!==(L=fe.order_global_min_separation_seconds)&&void 0!==L?L:null===(R=fe.order_rules)||void 0===R?void 0:R.global_min_separation_seconds)&&void 0!==D?D:0,me=null!==(P=null!==(j=fe.advertiser_global_min_separation_seconds)&&void 0!==j?j:null===(V=fe.advertiser_rules)||void 0===V?void 0:V.global_min_separation_seconds)&&void 0!==P?P:0,we=null!==(J=null!==(G=null===(F=fe.inventory_rules)||void 0===F?void 0:F.respect_inventory_code)&&void 0!==G?G:fe.respect_inventory_code)&&void 0!==J&&J,ye=null!==(W=null!==(B=null===(H=fe.break_code_rules)||void 0===H?void 0:H.respect_break_code)&&void 0!==B?B:fe.respect_break_code)&&void 0!==W&&W,he=(null===(K=Jn.get(i))||void 0===K?void 0:K.get(c))||qn,be=he.order_rules.enabled===ge>0&&he.order_rules.global_min_separation_seconds===Math.floor(ge/60)&&he.advertiser_rules.enabled===me>0&&he.advertiser_rules.global_min_separation_seconds===Math.floor(me/60)&&he.inventory_rules.respect_inventory_code===we&&he.break_code_rules.respect_break_code===ye;ue&&de&&ce&&_e&&pe&&be&&(le=!1)}le?(console.log("payloadv (update existing variant)",ae),T.push(h(ae,null!==(Y=null==ir?void 0:ir.email)&&void 0!==Y?Y:""))):(console.log("[saveEditedVariant] No changes for variant ".concat(t.variantId,", skipping API call")),T.push(Promise.resolve({data:{id:t.variantId},skipped:!0})))}})}),[4,Promise.all(T)];case 2:return k=i.sent(),console.log("✅ All variants updated:",k),ge(P),ye(!0),xe(!1),C=new Map,k.forEach(function(e,n){var t,i;if(!(null==e?void 0:e.skipped)){var r=M[n],a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.variant_id)||(null==e?void 0:e.id)||(null==e?void 0:e.variant_id);a||"string"!=typeof(null==e?void 0:e.data)||(a=e.data);var o="existing"===r.payloadType?r.existingId:a;if(o&&"string"==typeof o){var l=C.get(r.tierKey)||[];l.push({id:o,action:r.payloadType}),C.set(r.tierKey,l)}}}),I.getState().setCreatedVariantInfo(Array.from(C.entries()).map(function(e){return{tierName:e[0],variants:e[1]}})),null===(D=mi.current)||void 0===D||D.show({severity:"success",sticky:!1,life:3e3,className:S.toastSuccess,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(f,{className:S.iconSuccess}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleSuccess)},{children:"Success"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageSuccess)},{children:"Changes saved successfully!"}))]}))}),Ce.current=setTimeout(function(){ea()},3e3),[3,4];case 3:return N=i.sent(),console.error("❌ Error updating variant:",N),ge(F),ke(!0),xe(!1),E=(null===(j=null==N?void 0:N.response)||void 0===j?void 0:j.data)||{},console.log("errorData: ",E),(x="Variant already exists"===(null==E?void 0:E.message))||409===(null==N?void 0:N.status)?Ae('Looks like a similar rule already exists with the same conditions. You can update the description or conditions to make it unique, or discard this learning. <br/> How would you like to proceed?\n <br/><button class="clickable-button" data-value="Discard learning">Discard learning</button>\n <br/><button class="clickable-button" data-value="Continue editing learning">Continue editing learning</button>\n <br/><button class="clickable-button" id="typeYourAnswer">Or, type your response</button>'):Ae(((null==E?void 0:E.message)||(null==E?void 0:E.detail)||"Error Occurred while saving the rule.")+'Please try again.<br/><button class="clickable-button" data-value="Save this Learning">Retry</button>'),null===(V=mi.current)||void 0===V||V.show({severity:"error",sticky:!1,className:S.toastError,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(_,{className:S.iconError}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleError)},{children:"Error"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageError)},{children:x||409===(null==N?void 0:N.status)?"Similar rule already exists. Please update and try again.":(null==E?void 0:E.message)||(null==E?void 0:E.detail)||"Something went wrong while saving the learning!"}))]}))}),[3,4];case 4:return[2]}})})},jr=function(){return t(void 0,void 0,void 0,function(){var n,t,o,l,s,u,d,c,v,p,g,w,b,T,M,A,k,C,N,E,x,O,L,R,D,j,V;return i(this,function(i){switch(i.label){case 0:n=I.getState().tiers,t=Er(et,Ut,Jn),o=Nr(t),i.label=1;case 1:return i.trys.push([1,9,,10]),ge(G),Ae(""),0===(l=Array.isArray(vt)?vt:[]).length?(console.warn("No variants found to save."),ge(F),[2]):(s=l.filter(function(e){return e.is_new_variant}),u=l.filter(function(e){return!e.is_new_variant&&(null==e?void 0:e.variant_id)}),console.log("[saveLoadAndEditVariant] New: ".concat(s.length,", Existing: ").concat(u.length)),d=u.length>0?null===(R=u.find(function(e){return(null==e?void 0:e.link_id)&&""!==e.link_id.trim()}))||void 0===R?void 0:R.link_id:null,c=[],v=[],p=[],g=[],w=Cr(ve.tiers),ve.tiers.forEach(function(t){var i=t.toLowerCase().replace(/ /g,"_"),r=n.find(function(e){return e.tier_name.toLowerCase().replace(/ /g,"_")===i||e.tier_name.toLowerCase()===i.replace(/_/g,"")}),a=it.get(i),s=ot.get(i),u=ut.get(i);l.forEach(function(n,l){var _,f,y,b,T,M,A,I,S,k,C,N,E,x,O,L,R,D,j,V,P,F,G,J,H,B,W,K=(null==a?void 0:a.get(l))||n.rule_description||n.description||"",Y=(null==s?void 0:s.get(l))||[],z=(null==u?void 0:u.get(l))||[];if(n.is_new_variant){var Q=Er(et,Ut,Jn,l),Z=Nr(Q),ee=Lr(i,l,n.variant_type||n.variantType||""),ne={status:"approved",metadata:e(e({userName:null!==(_=null==ir?void 0:ir.firstname)&&void 0!==_?_:"",userEmailId:null!==(f=null==ir?void 0:ir.email)&&void 0!==f?f:"",llm:Fn.MODEL,isVariantFlow:!0},Z&&{config:e({master_name:Fn.CONFIG_MASTER_NAME},Z)}),{datasource:{type:"link",ref:"www.something.com",tag:"something"},variant:{tierLinkId:d||m(),variant:Ir(K),conditions_whentoapply:Y.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),conditions_whennottoapply:z.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),referenceVariantID:null,referenceVariantIDVersion:null,scope:w[0]||{name:Fn.SCOPE_NAME,parentScopeId:null,scopeRowId:(null==X?void 0:X.ruleSetId)||"",value:{scopeName:(null==X?void 0:X.ruleSetName)||"",scopeId:"Audacy_"+m(),customScopeGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,description:(null==X?void 0:X.ruleSetDesc)||""}},overriden:!1,isDefault:null!==(T=null===(b=null===(y=Jn.get(i))||void 0===y?void 0:y.get(l))||void 0===b?void 0:b.is_default_enabled)&&void 0!==T?T:U(n.variantType||n.variant_type||(0===l?"Default":"variant")),tier:{name:t.split(" ").join("").toLowerCase(),tierGroupName:Fn.CUSTOM_SCOPE_GROUP_NAME,tierPriority:parseInt(t.split(" ")[1]||"1"),tier_id:(null==r?void 0:r.tier_id)||""},topic:{id:null,value:"".concat(ve.station||$,"RuleSet"),description:null},categories:[{id:null,value:Fn.CATEGORY,description:Fn.CATEGORY}],originalQuestion:Zn,questionId:xn.current||null,variantType:ee,parameterizedQuestion:null,created_at:(new Date).toISOString(),created_by:null!==(M=null==ir?void 0:ir.email)&&void 0!==M?M:"",instantLearningType:Fn.INSTANT_LEARNING_TYPE,appliedTagsIL:[],tagMappingInfoIL:{},is_user_accepted_risk:!!(null!==(A=null==n?void 0:n.is_user_accepted_risk)&&void 0!==A?A:null==Lt?void 0:Lt.is_user_accepted_risk)},isAgentsFeedback:!0})};console.log("[saveLoadAndEditVariant] publish payload (new variant)",ne),v.push({payload:ne,tierKey:i}),g.push({tierKey:i})}else if(null==n?void 0:n.variant_id){p.push({tierKey:i,existingId:n.variant_id});var te=(null==n?void 0:n.variant_id)&&n.variant_id===nr?(null==Lt?void 0:Lt.variant_type)||n.variant_type||n.variantType||"":n.variant_type||n.variantType||"",ie=(ee=Lr(i,l,te),{variantId:n.variant_id,ruleDesc:(null==X?void 0:X.ruleSetDesc)||"",whenToApply:Y.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),whenNotToApply:z.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" OR "),isDefault:null!==(k=null===(S=null===(I=Jn.get(i))||void 0===I?void 0:I.get(l))||void 0===S?void 0:S.is_default_enabled)&&void 0!==k?k:U(n.variantType||n.variant_type||(0===l?"Default":"variant")),tier:{tier_id:(null==r?void 0:r.tier_id)||"",tier_name:(null==r?void 0:r.tier_name)||t,tier_priority:null!==(C=null==r?void 0:r.tier_priority)&&void 0!==C?C:null},scope_id:(null==X?void 0:X.ruleSetId)||"",description:Ir(K)||"",topic:"".concat(ve.station,"RuleSet"),configuration:(null==o?void 0:o.config_data)||{},tierLinkId:null!=d?d:null,variantType:ee,is_user_accepted_risk:!!(null!==(N=null==n?void 0:n.is_user_accepted_risk)&&void 0!==N?N:null===(E=(vt||[])[l])||void 0===E?void 0:E.is_user_accepted_risk),is_enabled:n.is_enabled}),re=(ft.get(i)||[]).find(function(e){return(null==e?void 0:e.variant_id)&&e.variant_id===(null==n?void 0:n.variant_id)}),ae=!0;if(re){var oe=function(e){var n=(e||"").trim();return(n=q(n)).replace(/\s+/g," ").replace(/(\s*OR\s*)/g," OR ")},le=oe(Zn)===oe(re.title),se=oe(K)===oe(re.rule_description),ue=oe(ie.whenToApply)===oe(re.wta),de=oe(ie.whenNotToApply)===oe(re.wnta),ce=!!ie.isDefault===U(re.variant_type),_e=re.scheduling_config||{},pe=null!==(L=null!==(x=_e.order_global_min_separation_seconds)&&void 0!==x?x:null===(O=_e.order_rules)||void 0===O?void 0:O.global_min_separation_seconds)&&void 0!==L?L:0,fe=null!==(j=null!==(R=_e.advertiser_global_min_separation_seconds)&&void 0!==R?R:null===(D=_e.advertiser_rules)||void 0===D?void 0:D.global_min_separation_seconds)&&void 0!==j?j:0,ge=null!==(F=null!==(P=null===(V=_e.inventory_rules)||void 0===V?void 0:V.respect_inventory_code)&&void 0!==P?P:_e.respect_inventory_code)&&void 0!==F&&F,me=null!==(H=null!==(J=null===(G=_e.break_code_rules)||void 0===G?void 0:G.respect_break_code)&&void 0!==J?J:_e.respect_break_code)&&void 0!==H&&H,we=(null===(B=Jn.get(i))||void 0===B?void 0:B.get(l))||qn,ye=we.order_rules.enabled===pe>0&&we.order_rules.global_min_separation_seconds===Math.floor(pe/60)&&we.advertiser_rules.enabled===fe>0&&we.advertiser_rules.global_min_separation_seconds===Math.floor(fe/60)&&we.inventory_rules.respect_inventory_code===ge&&we.break_code_rules.respect_break_code===me;le&&se&&ue&&de&&ce&&ye&&(ae=!1)}ae?(console.log("[saveLoadAndEditVariant] update payload (existing variant)",ie),c.push(h(ie,null!==(W=null==ir?void 0:ir.email)&&void 0!==W?W:""))):(console.log("[saveLoadAndEditVariant] No changes for variant ".concat(n.variant_id,", skipping API call")),c.push(Promise.resolve({data:{id:n.variant_id},skipped:!0})))}})}),[4,Promise.all(c)]);case 2:b=i.sent(),console.log("✅ All existing variants updated:",b),T=[],M=0,A=v,i.label=3;case 3:if(!(M<A.length))return[3,8];k=A[M],i.label=4;case 4:return i.trys.push([4,6,,7]),[4,y(k.payload,Fn.ASSISTANT_NAME)];case 5:return C=i.sent(),T.push(C),[3,7];case 6:throw N=i.sent(),console.error("❌ Error publishing new variant:",N),N;case 7:return M++,[3,3];case 8:return console.log("✅ All new variants published:",T),E=new Map,b.forEach(function(e,n){var t,i;if(!(null==e?void 0:e.skipped)){var r=p[n],a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.variant_id)&&e.data.variant_id||(null==e?void 0:e.id)||(null==e?void 0:e.variant_id)&&e.variant_id;a||"string"!=typeof(null==e?void 0:e.data)||(a=e.data);var o=r.existingId||a;if(o&&"string"==typeof o){var l=E.get(r.tierKey)||[];l.push({id:o,action:"existing"}),E.set(r.tierKey,l)}}}),T.forEach(function(e,n){var t,i,r=g[n],a=(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.id)||(null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.variant_id)&&e.data.variant_id||(null==e?void 0:e.id)||(null==e?void 0:e.variant_id)&&e.variant_id;if(a||"string"!=typeof(null==e?void 0:e.data)||(a=e.data),a&&"string"==typeof a){var o=E.get(r.tierKey)||[];o.push({id:a,action:"new"}),E.set(r.tierKey,o)}}),I.getState().setCreatedVariantInfo(Array.from(E.entries()).map(function(e){return{tierName:e[0],variants:e[1]}})),ge(P),ye(!0),xe(!1),Je.current=!1,null===(D=mi.current)||void 0===D||D.show({severity:"success",sticky:!1,life:3e3,className:S.toastSuccess,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(f,{className:S.iconSuccess}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleSuccess)},{children:"Success"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageSuccess)},{children:"Changes saved successfully!"}))]}))}),Ce.current=setTimeout(function(){ea()},3e3),[3,10];case 9:return x=i.sent(),console.error("❌ Error updating variant:",x),ge(F),ke(!0),xe(!1),O=(null===(j=null==x?void 0:x.response)||void 0===j?void 0:j.data)||{},console.log("errorData: ",O),(L="Variant already exists"===(null==O?void 0:O.message))||409===(null==x?void 0:x.status)?Ae('Looks like a similar rule already exists with the same conditions. You can update the description or conditions to make it unique, or discard this learning. <br/> How would you like to proceed?\n <br/><button class="clickable-button" data-value="Discard learning">Discard learning</button>\n <br/><button class="clickable-button" data-value="Continue editing learning">Continue editing learning</button>\n <br/><button class="clickable-button" id="typeYourAnswer">Or, type your response</button>'):Ae(((null==O?void 0:O.message)||(null==O?void 0:O.detail)||"Error Occurred while saving the rule.")+'Please try again.<br/><button class="clickable-button" data-value="Save this Learning">Retry</button>'),null===(V=mi.current)||void 0===V||V.show({severity:"error",sticky:!1,className:S.toastError,content:r("div",e({className:S.toastContent},{children:[r("div",e({className:S.toastHeaderLeft},{children:[a(_,{className:S.iconError}),a("span",e({className:"".concat(S.toastTitle," ").concat(S.toastTitleError)},{children:"Error"}))]})),a("p",e({className:"".concat(S.toastMessage," ").concat(S.toastMessageError)},{children:L||409===(null==x?void 0:x.status)?"Similar rule already exists. Please update and try again.":(null==O?void 0:O.message)||(null==O?void 0:O.detail)||"Something went wrong while saving the learning!"}))]}))}),[3,10];case 10:return[2]}})})},Vr=function(e){return"string"!=typeof e?e:e.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,"").trim()};d(function(){Ri&&!vi&&(console.log("isSaveRule received from agent — calling publish APIs directly."),Di(!1),ee||te?Dr():!0===Je.current?jr():t(void 0,void 0,void 0,function(){var e,n,t,r,a,o,l,s;return i(this,function(u){switch(u.label){case 0:u.trys.push([0,5,,6]),ge(G),e=new Map,n=function(n){var t,r,a,o,l,u;return i(this,function(i){switch(i.label){case 0:if(t=n.toLowerCase().replace(/ /g,"_"),r=Le.find(function(e){return e.tier_name.toLowerCase().replace(/ /g,"_")===t||e.tier_name.toLowerCase()===t.replace(/_/g,"")}),!(a=null==r?void 0:r.tier_id))return e.set(t,null),[2,"continue"];o={question:Zn,orgName:Fn.ORGANIZATION_NAME,scope_id:(null==X?void 0:X.ruleSetId)||"",tier_id:a},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,w(o)];case 2:return l=i.sent(),e.set(t,(null===(s=null==l?void 0:l.data)||void 0===s?void 0:s.id)||null),console.log("✅ Question saved for ".concat(n,":"),l),[3,4];case 3:return u=i.sent(),console.error("❌ Error saving question for ".concat(n,":"),u),e.set(t,null),[3,4];case 4:return[2]}})},t=0,r=ve.tiers,u.label=1;case 1:return t<r.length?(a=r[t],[5,n(a)]):[3,4];case 2:u.sent(),u.label=3;case 3:return t++,[3,1];case 4:return Rr(e),[3,6];case 5:return o=u.sent(),l=new Map,ve.tiers.forEach(function(e){l.set(e.toLowerCase().replace(/ /g,"_"),null)}),Rr(l),console.error("❌ Error saving Instant Learning Question:",o),[3,6];case 6:return[2]}})}))},[Ri,vi]);var Pr=(null===(H=(null===(J=null==ve?void 0:ve.tiers)||void 0===J?void 0:J[0])||ne||"Tier 1")||void 0===H?void 0:H.toLowerCase().replace(/ /g,"_"))||"tier_1",Fr=null!==(B=null!=kt?kt:ie)&&void 0!==B?B:0,Gr=null!=kt,qr=Gr?null==vt?void 0:vt[Fr]:null,Ur=vt&&(null==vt?void 0:vt.find(function(e){return e&&!e.is_readOnly&&((null==e?void 0:e.new_variant_id)&&Ft.includes(e.new_variant_id)||(null==e?void 0:e.variant_id)&&jt.includes(e.variant_id))})),Jr=(null==qr?void 0:qr.new_variant_id)&&Ft.includes(qr.new_variant_id)?qr.new_variant_id:(null==Ur?void 0:Ur.new_variant_id)&&Ft.includes(Ur.new_variant_id)?Ur.new_variant_id:"",Hr=!(!ee&&!te),Br=function(n){var t={},i=ve.tiers.map(function(e){return null==e?void 0:e.toLowerCase().replace(/ /g,"_")}),r=(null==ve?void 0:ve.station)+"RuleSet",a=i.map(function(e){var n=Le.find(function(n){return n.tier_name.toLowerCase().replace(/ /g,"_")===e||n.tier_name.toLowerCase()===e.replace(/_/g,"")});return(null==n?void 0:n.tier_id)||""}).filter(Boolean);return n.forEach(function(n,o){var l,s,u,d,c,v,_=(null==n?void 0:n.variant_id)&&n.variant_id||jt[o]||"new_variant_".concat(o),p=(null===(l=n.scope)||void 0===l?void 0:l[0])||Pr,f=it.get(p),g=ot.get(p),m=ut.get(p),w=(null==f?void 0:f.get(o))||n.rule_description||"",y=(null==g?void 0:g.get(o))||[],h=y.length>0?y.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" \\n "):n.wta||"",b=(null==m?void 0:m.get(o))||[],T=b.length>0?b.map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" \\n "):n.wnta||"",M=Jn.get(p),A=null==M?void 0:M.get(o),I={};A&&Object.keys(A).length>0?I=e(e({},A),{order_rules:e(e({},A.order_rules),{global_min_separation_seconds:60*((null===(s=A.order_rules)||void 0===s?void 0:s.global_min_separation_seconds)||0)}),advertiser_rules:e(e({},A.advertiser_rules),{global_min_separation_seconds:60*((null===(u=A.advertiser_rules)||void 0===u?void 0:u.global_min_separation_seconds)||0)})}):n.scheduling_config&&(I=n.scheduling_config),t[_]={rule_title:Zn,variant_description:w,wta:h,ruleset_id:(null==X?void 0:X.ruleSetId)||"",tier_id:a,wnta:T,scope:i,scope_rule_set:r,scheduling_config:I,is_user_accepted_risk:!(null===(v=null!==(d=null==n?void 0:n.is_user_accepted_risk)&&void 0!==d?d:null===(c=(vt||[])[o])||void 0===c?void 0:c.is_user_accepted_risk)||void 0===v||!v)}}),t};wn&&console.log("customMetaData.ui_state for addvariant flow",Br(wt));var Wr={send_metadata_to_orchestrator:!1,default:["scope"],ui_state:Hr?{variants:function(){var n={},t=Jn.get(Pr);if(!t)return n;var i=it.get(Pr),r=ot.get(Pr),a=ut.get(Pr),o=ve.tiers.map(function(e){return null==e?void 0:e.toLowerCase().replace(/ /g,"_")}),l=(null==ve?void 0:ve.station)+"RuleSet",s=o.map(function(e){var n=Le.find(function(n){return n.tier_name.toLowerCase().replace(/ /g,"_")===e||n.tier_name.toLowerCase()===e.replace(/_/g,"")});return(null==n?void 0:n.tier_id)||""}).filter(Boolean);return t.forEach(function(u,d){var c,v,_,p,f,g,m=null===(c=null==te?void 0:te[d])||void 0===c?void 0:c.variantId,w=(vt||[])[d],y=(null==w?void 0:w.new_variant_id)||"",h=m||y||jt[d]||"variant_".concat(d),b=(null==i?void 0:i.get(d))||"",T=((null==r?void 0:r.get(d))||[]).map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" \\n ")||"",M=((null==a?void 0:a.get(d))||[]).map(function(e){return e.text}).filter(function(e){return""!==e.trim()}).join(" \\n ")||"",A=t.get(d),I={};A&&Object.keys(A).length>0&&(I=e(e({},A),{order_rules:e(e({},A.order_rules),{global_min_separation_seconds:60*((null===(v=A.order_rules)||void 0===v?void 0:v.global_min_separation_seconds)||0)}),advertiser_rules:e(e({},A.advertiser_rules),{global_min_separation_seconds:60*((null===(_=A.advertiser_rules)||void 0===_?void 0:_.global_min_separation_seconds)||0)})})),n[h]={rule_title:Zn,variant_description:b,wta:T,ruleset_id:(null==X?void 0:X.ruleSetId)||"",tier_id:s,wnta:M,scope:o,scope_rule_set:l,scheduling_config:I,is_user_accepted_risk:!(null===(g=null!==(p=null==w?void 0:w.is_user_accepted_risk)&&void 0!==p?p:null===(f=null==te?void 0:te[d])||void 0===f?void 0:f.is_user_accepted_risk)||void 0===g||!g)}}),n}()}:function(){var n,t,i,r,a,o,l=(vt||[]).findIndex(function(e){return!0===e.is_new_variant}),s=-1;return-1!==l?s=l:vn?s=-1:wn||(s=Fr),{new_current_variant:-1!==s?{rule_title:Zn,rule_description:(null===(n=it.get(Pr))||void 0===n?void 0:n.get(s))||"",wta:(null===(i=null===(t=ot.get(Pr))||void 0===t?void 0:t.get(s))||void 0===i?void 0:i.map(function(e){return Vr(e.text)}).filter(function(e){return""!==e}).join(" \\n "))||"",wnta:(null===(a=null===(r=ut.get(Pr))||void 0===r?void 0:r.get(s))||void 0===a?void 0:a.map(function(e){return Vr(e.text)}).filter(function(e){return""!==e}).join(" \\n "))||"",scope:ve.tiers.map(function(e){return null==e?void 0:e.toLowerCase().replace(/ /g,"_")}),scope_rule_set:(null==ve?void 0:ve.station)+"RuleSet",scheduling_config:function(){var n,t,i,r=null===(n=Jn.get(Pr))||void 0===n?void 0:n.get(s);return r&&0!==Object.keys(r).length?e(e({},r),{order_rules:e(e({},r.order_rules),{global_min_separation_seconds:60*((null===(t=r.order_rules)||void 0===t?void 0:t.global_min_separation_seconds)||0)}),advertiser_rules:e(e({},r.advertiser_rules),{global_min_separation_seconds:60*((null===(i=r.advertiser_rules)||void 0===i?void 0:i.global_min_separation_seconds)||0)})}):{}}(),is_user_accepted_risk:!!(null===(o=(vt||[])[s])||void 0===o?void 0:o.is_user_accepted_risk)}:{rule_title:"",rule_description:"",wta:"",wnta:"",scope:[],scope_rule_set:"",scheduling_config:{},is_user_accepted_risk:!1},variants:wn?Br(wt):{}}}(),rule_id_in_current_session:At,new_variant_id:function(){var e;return Gr&&ee?(null===(e=null==te?void 0:te[Fr])||void 0===e?void 0:e.variantId)?null:Jr:null}(),edit_variant_id:Nn,rule_id:xn.current,ruleset_id:(null==X?void 0:X.ruleSetId)||"",current_variants_length:ee?Array.isArray(vt)&&vt.length>0?Math.max((null===(W=null==ee?void 0:ee.variants)||void 0===W?void 0:W.length)||0,vt.length):null===(K=null==ee?void 0:ee.variants)||void 0===K?void 0:K.length:void 0,tiers:Le,authToken:(null==ir?void 0:ir.accessToken)||""},Kr=br(wt),Yr={ruleTitle:Zn,scopeData:ve,variantsByTier:Array.from(Jn.keys()).reduce(function(n,t){var i=Jn.get(t)||new Map,r=it.get(t)||new Map,a=ot.get(t)||new Map,o=ut.get(t)||new Map;return console.log("tier config map",i),n[t]=Array.from(i.keys()).map(function(n,l){var s,u,d=(vt||[])[n]||{};console.log("Original item for tier",t,"index",n,":",d);var c={label:"",isDefault:!1};if(d.is_variant&&!U(d.variant_type))c={label:"",isDefault:!1};else if(te&&te.length>0){c=xr(te,n,"variantType"),console.log("Found matching variant at index",n,":",c);var v=te[n];if(v){if(!c.label){var _=v.variantType||"",p=U(_);c={label:"variant ".concat(n+1),isDefault:p}}if(v.variantId===zi)(g=d.variant_type||(null==Lt?void 0:Lt.variant_type))&&(c=Or(g,n),console.log("[templateState] editingVariants[".concat(n,']: using CARE variant_type "').concat(g,'" → label "').concat(c.label,'"')));console.log("Computed variant type at index",n,":",c)}else c={label:br(te),isDefault:!1},console.log("No match found, using getNextVariantType:",c)}else if(wt&&wt.length>0){if(c=xr(wt,n,"variant_type"),console.log("Found matching variant at index",n,":",c),Je.current){var f=wt[n];if((null==f?void 0:f.variant_id)===nr||(null==f?void 0:f.variantId)===nr)(g=d.variant_type||(null==Lt?void 0:Lt.variant_type))&&(c=Or(g,n),console.log("[templateState] existingVariants[".concat(n,']: load-and-edit using CARE variant_type "').concat(g,'" → label "').concat(c.label,'"')))}}else{var g=d.variant_type||"";c={label:Kr,isDefault:U(g)}}console.log("Computed variant data for tier",t,"index",n,":",c);var m=null!==(u=null===(s=i.get(n))||void 0===s?void 0:s.is_default_enabled)&&void 0!==u?u:c.isDefault;console.log("live is default :",m);var w="variant ".concat(l+1),y=r.get(n)||"";return{variantId:jt[n]||d.variant_id||d.variantId,variantType:w,isDefault:m,isModified:d.is_modified,tier:t,index:n,ruleDescription:y.replace(/<ai_reasoning>[\s\S]*?<\/ai_reasoning>/g,""),whenToApplyConditions:(a.get(n)||[]).flatMap(function(n){var t,i=(null===(t=null==n?void 0:n.text)||void 0===t?void 0:t.split(/\s+OR\s+/))||[];return i.length>1?i.map(function(t,i){return e(e({},n),{id:"split-".concat(n.id,"-").concat(i),text:t.trim()})}):[n]}),whenNotToApplyConditions:(o.get(n)||[]).flatMap(function(n){var t,i=(null===(t=null==n?void 0:n.text)||void 0===t?void 0:t.split(/\s+OR\s+/))||[];return i.length>1?i.map(function(t,i){return e(e({},n),{id:"split-".concat(n.id,"-").concat(i),text:t.trim()})}):[n]}),configData:i.get(n)||qn,isReadOnly:d.is_readOnly||!1,is_variant:d.is_variant||!1,reasoning:{ruleDescription:Ar(y),whenToApply:Ar(d.wta),whenNotToApply:Ar(d.wnta),configData:Ar(d.action)}}}),n},{}),citation:ei,fieldCitations:ui,citations:ii};console.log("templateState",Yr);var zr={setRuleTitle:function(n){var t,i=void 0!==(null===(t=null==n?void 0:n.target)||void 0===t?void 0:t.value)?n.target.value:n;$n(i),Si(function(n){if(n.ruleTitle){var t=e({},n);return delete t.ruleTitle,t}return n})},setRuleDescription:function(e,n,t){return ur(e,n,t)},addWhenToApply:function(e,n){return dr(e,n)},removeWhenToApply:function(e,n,t){return cr(e,n,t)},editWhenToApply:function(e,n,t,i){return vr(e,n,t,i)},addWhenNotToApply:function(e,n){return _r(e,n)},removeWhenNotToApply:function(e,n,t){return pr(e,n,t)},editWhenNotToApply:function(e,n,t,i){return fr(e,n,t,i)},addNewVariant:function(e){return gr(e)},onScopeChange:wr,onConfigChange:function(e,n,t,i){return yr(e,n,t,i)}},Qr={},Zr={};Jn.forEach(function(n,t){Qr[t]=new Map,Zr[t]=new Map,n.forEach(function(n,i){Qr[t].set(i,[e({key:"order_rules",label:"Order"},n.order_rules),e({key:"advertiser_rules",label:"Advertiser"},n.advertiser_rules)]),Zr[t].set(i,[{key:"inventory_rules",label:"Inventory code",enabled:n.inventory_rules.respect_inventory_code},{key:"break_code_rules",label:"Break Code",enabled:n.break_code_rules.respect_break_code},{key:"is_default_enabled",label:"Default Variant",enabled:n.is_default_enabled}])})});var $r=v(function(){if(ne){if(1===ve.tiers.length)return 0;var e=ve.tiers.findIndex(function(e){return e.toLowerCase()===ne.toLowerCase()});return e>=0?e:0}},[ne,ve.tiers]),Xr=e(e({defaultOpen:!0,tierOptions:["Tier 1","Tier 2"],stationOptions:[{label:"Global Scope",value:"global"},{label:"Genre Scope",value:"genre"},{label:"Custom Scope",value:"custom"}],separationItemsByTier:Qr,togglesByTier:Zr,highlights:Bt,highlightedIds:Yt,openSections:Wn,setOpenSections:Kn,setSendMessageInChat:xt,isAiStreaming:vi,defaultTierOpen:$r,defaultVariantOpen:vn?void 0:kt,autoScrollVariantIndex:vn?void 0:kt,activeVariantAccordionIndex:vn?void 0:kt,setActiveVariantAccordionIndex:function(e){Ct(e),null!=e&&setTimeout(function(){_n(!1)},100)},validationErrors:Ii,activeEditId:Mn,setActiveEditId:An,pendingEditId:Sn,setPendingEditId:kn,conflictReason:Ci,usedFor:ee||te?"Edit":"Create"},Gn),{scrollTrigger:Zt});console.log(kt,"editVariantIndex checking"),d(function(){},[z]),d(function(){if(!vi&&bt&&!!(!ee&&!te)){var e=n([],vt,!0).reverse().findIndex(function(e){return"variant"===e.action||e.is_variant});-1===e||vt.length,-1!==e&&(console.log("Post-stream: Focusing new variant at index",e),Ct(e))}},[vi,bt]);var ea=function(){Ce.current&&(clearTimeout(Ce.current),Ce.current=null),Je.current=!1,Q(),hr()},na=function(){var e={};Zn.trim()||(e.ruleTitle="Rule Title is required"),ve.station||(e.station="Station Rule Set is required"),ve.tiers&&0!==ve.tiers.length||(e.tiers="At least one tier must be selected");return ve.tiers.map(function(e){return e.toLowerCase().replace(/ /g,"_")}).forEach(function(n){var t=it.get(n),i=ot.get(n),r=Jn.get(n);r&&Array.from(r.keys()).forEach(function(r){var a=null==t?void 0:t.get(r);a&&a.trim()||(e["ruleDescription-".concat(n,"-").concat(r)]="Rule Description is required");var o=null==i?void 0:i.get(r);o&&o.some(function(e){return""!==e.text.trim()})||(e["whenToApply-".concat(n,"-").concat(r)]='At least one "When to apply" condition is required')})}),e};function ta(r,a,o){var l,s,u,d,c,v;return void 0===o&&(o=!1),t(this,void 0,void 0,function(){var t,_,p,f,g,m,w,y,h,T,M,A,I,S,k,C,N,E,x,O,L,R,D,j;return i(this,function(i){switch(i.label){case 0:if(t=r.question_id,_=(null==r?void 0:r.variant_id)||null,hn.current&&Ln.current===t)return console.log("[handleAILoadAction] Already fetching question ID, skipping duplicate request:",t),[2];if(xn.current===t&&!o)return console.log("[handleAILoadAction] Question ID unchanged, updating variant focus only:",_),En(_),_?(-1!==(p=(vt||[]).findIndex(function(e){return e.is_new_variant}))&&(Mi(!0),qi("Removing new variant..."),Hi("Please wait while we remove new variant.")),_t(function(e){if(!Array.isArray(e))return e;var n=e.filter(function(e){return!e.is_new_variant}),t=n.findIndex(function(e){return e.variant_id===_});return-1!==t&&setTimeout(function(){Ct(t),$t(function(e){return e+1}),gi.current=t},0),n}),-1!==p&&((f=function(e){e(function(e){var n=new Map;return e.forEach(function(e,t){var i=new Map(e);i.delete(p);var r=new Map,a=0;i.forEach(function(e){r.set(a,e),a++}),n.set(t,r)}),n})})(Hn),f(rt),f(lt),f(dt),Vt(function(e){var t=n([],e,!0);return t.length>p&&t.splice(p,1),t})),!1===hn.current&&(hn.current=!0,-1!==p&&(null===(l=mi.current)||void 0===l||l.show({severity:"success",summary:"Success",detail:"New variant removed successfully because you selected to edit an existing variant",life:4e3}))),_n(!1)):(console.log("lastLoadedQuestionIdRef.current in else",xn.current),null===xn.current&&(Mi(!0),qi("Adding new variant..."),Hi("Please wait while we add new variant."))),[2];console.log("User Action: fetching fresh variant info for question",t),bn.current.clear(),bn.current.add(t),Mi(!0),qi("Loading variants..."),console.log("reaching here in load and edit"),Hi("Please wait while we fetch the latest variant data."),hn.current=!0,Ln.current=t,i.label=1;case 1:return i.trys.push([1,5,6,10]),g=Date.now(),[4,b(t,(null==X?void 0:X.ruleSetId)||"")];case 2:return m=i.sent(),(w=Date.now()-g)<3e3?[4,new Promise(function(e){return setTimeout(e,3e3-w)})]:[3,4];case 3:i.sent(),i.label=4;case 4:return 0===(y=(null===(s=null==m?void 0:m.data)||void 0===s?void 0:s.variants)||[]).length?(console.warn("No variants found for question_id",t),Mi(!1),qi(""),null===(u=mi.current)||void 0===u||u.show({severity:"error",summary:"Error",detail:"No variants found for this question.",life:3e3}),[2]):(Je.current=!0,hn.current=!0,h=(null===(d=null==m?void 0:m.data)||void 0===d?void 0:d.ruleTitle)||"",$n(h),T=null===(c=null==m?void 0:m.data)||void 0===c?void 0:c.tier,M="tier_1",A="Tier 1",I="1",T&&((S=String(T).match(/(\d+)/))?(k=S[1],I=k,M="tier_".concat(k),A="Tier ".concat(k)):(M=String(T).toLowerCase().trim().replace(/ /g,"_"),A=M.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),I=M.includes("2")?"2":"1")),console.log("[handleAILoadAction] Detected Tier: ".concat(A," (ID: ").concat(I,", Key: ").concat(M,")")),_e({station:$||"global",tiers:[A]}),C=function(e,n,t,i,r,a){var o=e.map(function(e){var o,l,s=[t];return{variant_type:e.variantType||"variant",title:n,rule_description:e.description||"",wta:e.whenToApply||"",wnta:e.whenNotToApply||"",scope:s,scheduling_config:(null===(o=e.configuration)||void 0===o?void 0:o.scheduling_config)||{},variant_id:e.variantId,question_id:r,tier_id:i,is_readOnly:e.variantId!==a,link_id:e.link_id||"",is_enabled:null===(l=e.is_enabled)||void 0===l||l,is_user_accepted_risk:e.is_user_accepted_risk,has_accepted_risk:e.has_accepted_risk,user_accepted_risk_at:e.user_accepted_risk_at,action:"edit"}}),l=new Map,s=new Map,u=new Map,d=new Map;return o.forEach(function(e,n){var t,i,r,a,o,c,v=e.scheduling_config||{};l.set(n,{order_rules:{enabled:!!v.order_global_min_separation_seconds||!!(null===(t=v.order_rules)||void 0===t?void 0:t.global_min_separation_seconds),global_min_separation_seconds:Math.floor((v.order_global_min_separation_seconds||(null===(i=v.order_rules)||void 0===i?void 0:i.global_min_separation_seconds)||0)/60)},advertiser_rules:{enabled:!!v.advertiser_global_min_separation_seconds||!!(null===(r=v.advertiser_rules)||void 0===r?void 0:r.global_min_separation_seconds),global_min_separation_seconds:Math.floor((v.advertiser_global_min_separation_seconds||(null===(a=v.advertiser_rules)||void 0===a?void 0:a.global_min_separation_seconds)||0)/60)},inventory_rules:{respect_inventory_code:!!v.respect_inventory_code||!!(null===(o=v.inventory_rules)||void 0===o?void 0:o.respect_inventory_code)},break_code_rules:{respect_break_code:!!v.respect_break_code||!!(null===(c=v.break_code_rules)||void 0===c?void 0:c.respect_break_code)},is_default_enabled:U(e.variantType||e.variant_type)}),s.set(n,q(e.rule_description||""));var _=e.wta?e.wta.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];u.set(n,_);var p=e.wnta?e.wnta.split(" OR ").map(function(e){return e.trim()}).filter(function(e){return""!==e}).map(function(e,t){return{id:"edit-wnta-".concat(n,"-").concat(t),text:e,reasoning:""}}):[];d.set(n,p)}),{transformedVariants:o,tierConfigMap:l,tierDescMap:s,tierWtaMap:u,tierWntaMap:d}}(y,h,M,I,t,_),N=C.transformedVariants,E=C.tierConfigMap,x=C.tierDescMap,O=C.tierWtaMap,L=C.tierWntaMap,gt(function(e){var n=new Map(e);return n.set(M,JSON.parse(JSON.stringify(N))),n}),_t(function(e){var t=(Array.isArray(e)?e:[]).filter(function(e){return"copy"===e.action||e.tier_id&&e.tier_id!==I});return n(n([],t,!0),N,!0)}),yt(function(e){var t=(Array.isArray(e)?e:[]).filter(function(e){return"copy"===e.action||e.tier_id&&e.tier_id!==I});return n(n([],t,!0),N,!0)}),yn(!0),xn.current=t,En(_),R=0,_&&-1!==(D=N.findIndex(function(e){return e.variant_id===_}))&&(R=D),Ct(R),$t(function(e){return e+1}),gi.current=R,_n(!1),Hn(function(e){var n=new Map(e);return n.set(M,E),n}),rt(function(e){var n=new Map(e);return n.set(M,x),n}),lt(function(e){var n=new Map(e);return n.set(M,O),n}),dt(function(e){var n=new Map(e);return n.set(M,L),n}),Si({}),[3,10]);case 5:return j=i.sent(),console.error("Failed to fetch variants by question ID:",j),null===(v=mi.current)||void 0===v||v.show({severity:"error",summary:"Error",detail:"Failed to fetch variants. Please try again.",life:3e3}),[3,10];case 6:return hn.current=!1,Mi(!1),qi(""),Hi(""),(null==r?void 0:r.is_interpretation_ready)&&(null==r?void 0:r.question_id)&&xn.current&&Nn?(console.log("inside edit variant flow",xn.current,Nn),_t(function(n){if(!Array.isArray(n))return n;var t=n.map(function(n){return(null==n?void 0:n.variant_id)===Nn?e(e({},n),a):n}),i=n.findIndex(function(e){return(null==e?void 0:e.variant_id)===Nn});return console.log(i,"targetIndexif"),-1!==i&&setTimeout(function(){console.log("targetIndex",i),Ct(i),$t(function(e){return e+1}),gi.current=i},0),t}),[3,9]):[3,7];case 7:return(null==r?void 0:r.is_interpretation_ready)&&(null==r?void 0:r.question_id)&&xn.current&&!Nn?(console.log("inside add new variant flow",xn.current,Nn),Mi(!0),qi("Adding new variant..."),Hi("Please wait while we add new variant."),[4,new Promise(function(e){return setTimeout(e,3e3)})]):[3,9];case 8:i.sent(),Mi(!1),qi(""),Hi(""),_t(function(t){var i;if(Array.isArray(t)){var r=t.findIndex(function(e){return!0===e.is_new_variant});if(-1!==r)setTimeout(function(){Ct(r),$t(function(e){return e+1}),gi.current=r},0),i=t.map(function(n,t){return t===r?e(e(e({},n),a),{is_new_variant:!0,is_variant:!0}):n});else{var o=t.length;setTimeout(function(){Ct(o),$t(function(e){return e+1}),gi.current=o},0),i=n(n([],t,!0),[e(e({},a),{is_new_variant:!0,is_variant:!0})],!1)}}else setTimeout(function(){Ct(0),$t(0),gi.current=0},0),i=[e(e({},a),{is_new_variant:!0})];return jn.current=i,i}),i.label=9;case 9:return[7];case 10:return[2]}})})}console.log("RuleSet in render",X);var ia;return r(o,{children:[a(g,{ref:mi}),a(k,{open:z,chatAssistantName:Fn.ASSISTANT_NAME,organizationName:Fn.ORGANIZATION_NAME,baseUrl:Fn.BASE_URL,baseWebsocketUrl:Fn.BASE_WEBSOCKET_URL,closeFunction:ea,ThinkingBulbIconComponent:a(j,{}),customSections:a(o,{}),customMetaData:Wr,chatTitle:ee?Fn.CHAT_TITLE_EDIT.replace("<scope>",(null==X?void 0:X.ruleSetName)||""):Fn.CHAT_TITLE.replace("<scope>",(null==X?void 0:X.ruleSetName)||""),formTitle:Fn.FORM_TITLE,showSavedMessage:!1,savedMessage:be,isError:Se,errorMessage:Me,isSaving:Ee,onSave:function(e){console.log("Save this Learning",e);var n=na();if(Object.keys(n).length>0)return console.log("validation errors",n),void Si(n);xe(!0),ke(!1),Ae("")},showSaveWithoutValidation:!1,onSaveWithoutValidation:function(){return t(void 0,void 0,void 0,function(){var e,n,t,r,a,o,l,s,u;return i(this,function(d){switch(d.label){case 0:return e=na(),Object.keys(e).length>0?(Si(e),[2]):(console.log("✅ Bypass Save: Initiated"),ee||te?[4,Dr()]:[3,2]);case 1:return d.sent(),[3,11];case 2:return!0!==Je.current?[3,4]:[4,jr()];case 3:return d.sent(),[3,11];case 4:d.trys.push([4,10,,11]),ge(G),n=new Map,t=function(e){var t,r,a,o,l,s;return i(this,function(i){switch(i.label){case 0:if(t=e.toLowerCase().replace(/ /g,"_"),r=Le.find(function(e){return e.tier_name.toLowerCase().replace(/ /g,"_")===t||e.tier_name.toLowerCase()===t.replace(/_/g,"")}),!(a=null==r?void 0:r.tier_id))return n.set(t,null),[2,"continue"];o={question:Zn,orgName:Fn.ORGANIZATION_NAME,scope_id:(null==X?void 0:X.ruleSetId)||"",tier_id:a},i.label=1;case 1:return i.trys.push([1,3,,4]),[4,w(o)];case 2:return l=i.sent(),n.set(t,(null===(u=null==l?void 0:l.data)||void 0===u?void 0:u.id)||null),[3,4];case 3:return s=i.sent(),console.error("❌ Bypass Save: Error saving question for ".concat(e,":"),s),n.set(t,null),[3,4];case 4:return[2]}})},r=0,a=ve.tiers,d.label=5;case 5:return r<a.length?(o=a[r],[5,t(o)]):[3,8];case 6:d.sent(),d.label=7;case 7:return r++,[3,5];case 8:return[4,Rr(n,!0)];case 9:return d.sent(),[3,11];case 10:return l=d.sent(),ge(F),s=new Map,ve.tiers.forEach(function(e){s.set(e.toLowerCase().replace(/ /g,"_"),null)}),Rr(s,!0),console.error("❌ Bypass Save: Error",l),[3,11];case 11:return[2]}})})},headerMessageHandlers:Mr,aiResponse:vt,setAIResponse:_t,width:"90vw",height:"90vh",sendMessageInChat:Et,template:C.CreateRule,isLoading:fe===G,templateProps:{state:Yr,handlers:zr,uiState:Xr},setSendMessageInChat:xt,onResetChat:function(){hr()},onResetRequest:function(){hi(!0)},isFormDirty:function(){return""!==Zn.trim()||""!==ve.station||ve.tiers.length>0||Array.from(it.values()).some(function(e){return Array.from(e.values()).some(function(e){return""!==e.trim()})})||Array.from(ot.values()).some(function(e){return Array.from(e.values()).some(function(e){return e.length>0})})||Array.from(ut.values()).some(function(e){return Array.from(e.values()).some(function(e){return e.length>0})})||Jn.size>0||et.size>0},initialChatMessage:ee?(ia=ee.ruleTitle||"this rule",null===(Y=null==te?void 0:te[null!=ie?ie:0])||void 0===Y||Y.is_user_accepted_risk,'<p><span>Welcome back! 👋</span>\n <span>I see you want to edit <strong>"'.concat(ia,'."</strong></span>\n <span> <strong>What would you like to update? </strong> </span>\n <span>Describe the change you want to make, and I’ll help you edit it.</span>\n </p>')):Fn.INITIAL_CHAT_MESSAGE,validateCustom:function(){if(fe===P||we)return!1;if(!Zn||""===Zn.trim())return!1;if(null!==Mn)return!1;if(!ve.station||""===ve.station.trim())return!1;var e=ve.tiers&&ve.tiers.filter(function(e){return e&&""!==e.trim()});if(!e||0===(null==e?void 0:e.length))return!1;for(var n,t=0,i=e.map(function(e){return e.toLowerCase().replace(/ /g,"_")});t<i.length;t++){var r=i[t],a=it.get(r),o=ot.get(r),l=Jn.get(r);if(!l||0===l.size)return!1;for(var s=0,u=Array.from(l.keys());s<u.length;s++){var d=u[s],c=null==a?void 0:a.get(d);if(!c||""===c.trim())return!1;var v=null==o?void 0:o.get(d);if(!(null==v?void 0:v.some(function(e){return e.text&&""!==e.text.trim()})))return!1}}return!(!Jn||0===Jn.size)&&(!(n=function(e){return Array.from(e.values()).some(function(e){return Array.from(e.values()).some(function(e){return e.some(function(e){return!!e.conflict})})})})(ot)&&!n(ut)&&!Ye)},setCitations:ri,isLocked:!0,textareaPlaceholder:"Tell me more about this learning..",saveButtonConfig:{label:ee?"Save Changes":"Save Learning",loadingLabel:r("span",e({style:{display:"flex",gap:"5px",alignItems:"center"}},{children:[a(p,{size:20,color:"white",className:"animate-spin"}),a("span",{children:" Saving Changes..."})]}))},setCurrentRequestId:li,isAiStreaming:vi,setIsAiStreaming:_i,showConfirmReset:yi,setShowConfirmReset:hi,confirmReset:function(){hr(),hi(!1),ea()},isLoadingVariants:Ti,mainText:Gi,subText:Ji,proposedRule:Xe,isFetchingComparison:sr,handleOpenComparison:Tr,showComparison:Vi,setShowComparison:Pi,variants:tn,onComparisonLinkClick:lr,targetComparisonVariantId:on,highlightedComparisonField:un,onAddAsVariant:function(){Pi(!1)},isCopyEnabled:!0,onSubmitFeedback:function(n){return t(void 0,void 0,void 0,function(){var t,r,a,o,l;return i(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=e({user_id:null!==(a=null==ir?void 0:ir._id)&&void 0!==a?a:"",user_name:null!==(o=null==ir?void 0:ir.firstname)&&void 0!==o?o:"",user_email:null!==(l=null==ir?void 0:ir.email)&&void 0!==l?l:"",assistant_name:Fn.ASSISTANT_NAME},n),[4,T(t)];case 1:return i.sent(),[3,3];case 2:throw r=i.sent(),console.error("Failed to submit chat feedback",r),r;case 3:return[2]}})})},handleGlobalClickCapture:function(e){null!==Mn&&(e.target.closest('[data-edit-id="'.concat(Mn,'"]'))||(e.preventDefault(),e.stopPropagation(),kn(Mn)))},isGlobalEditActive:null!==Mn,initialDraftMessage:le?de:"",socketTimeOutInMilliSeconds:Fn.SOCKET_TIMEOUT,onValidateSession:function(e){return t(void 0,void 0,void 0,function(){var n,t;return i(this,function(i){switch(i.label){case 0:if(n=null==X?void 0:X.ruleSetId,console.log("Validating session for scope_id:",n,"sessionStartTime:",e),!n)return console.warn("No scope_id found for session validation."),[2,!1];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,M({scope_id:n,session_start_time:e})];case 2:return[2,i.sent()];case 3:return t=i.sent(),console.error("Session validation failed",t),[2,!1];case 4:return[2]}})})}})]})};export{J as default,q as filterAgentText};
|
|
2
|
+
//# sourceMappingURL=InstantLearningModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstantLearningModal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"tslib";var _,e={VITE_GOOGLE_CLIENT_ID:process.env.VITE_GOOGLE_CLIENT_ID,VITE_GOOGLE_CLIENT_SECRET:process.env.VITE_GOOGLE_CLIENT_SECRET,VITE_REDIRECT_URI:process.env.VITE_REDIRECT_URI||"http://localhost:5173",VITE_BACKEND_URL:process.env.VITE_BACKEND_URL||"http://localhost:3000",VITE_DOMAIN_NAME_URL:process.env.VITE_DOMAIN_NAME_URL||"https://devllmstudio.creativeworkspace.ai",VITE_ASSISTANT_NAME:process.env.VITE_ASSISTANT_NAME||"cwchatorchestrator",VITE_PROJECT_CREATION_ASSISTANT_NAME:process.env.VITE_PROJECT_CREATION_ASSISTANT_NAME||"cwprojectcreation",VITE_WEBSOCKET_URL:process.env.VITE_WEBSOCKET_URL||"wss://dev-proposals-ai.techo.camp/graphql",VITE_AUDACY_BACKEND_URL:process.env.VITE_AUDACY_BACKEND_URL||"",VITE_AUDACY_WEBSOCKET_URL:process.env.VITE_AUDACY_WEBSOCKET_URL||"",VITE_AUDACY_ASSISTANT_NAME:process.env.VITE_AUDACY_ASSISTANT_NAME||"",VITE_AUDACY_RECOMMEND_AGENT:process.env.VITE_AUDACY_RECOMMEND_AGENT||"",VITE_AUDACY_COMPARE_AGENT:process.env.VITE_AUDACY_COMPARE_AGENT||"",VITE_AUDACY_CHAT_ASSISTANT:process.env.VITE_AUDACY_CHAT_ASSISTANT||"",VITE_CORE_WHITELIST_URLS:(null===(_=process.env.VITE_CORE_WHITELIST_URLS)||void 0===_?void 0:_.split(",").map(function(_){return _.trim()}))||[],VITE_LLM_STUDIO_URL:process.env.VITE_LLM_STUDIO_URL||"https://devllmstudio.creativeworkspace.ai",VITE_LLM_STUDIO_WEBSOCKET_URL:process.env.VITE_LLM_STUDIO_WEBSOCKET_URL||"wss://devllmstudio.creativeworkspace.ai/graphql",VITE_AUDACY_RULE_ASSISTANT:process.env.VITE_AUDACY_RULE_ASSISTANT},E={"Separation rule":"I want to add a separation rule","Max priority":"I want to set a max priority","Break code matching":"I want to add a break code matching rule","Inventory window matching":"I want to add an inventory window matching rule","Enter a learning description":"I want to add a learning description","Tester Genie":"Finding an interesting usecase to test..."},T="<p><span>Hi! 👋 I'm your Instant Learning Concierge.</span>\n <span>How would you like to get started? You can select an option below or describe the learning you'd like to create.</span>\n ".concat(["Separation rule","Max priority","Break code matching","Inventory window matching","Enter a learning description"].map(function(_){return'<button class="clickable-button" data-value="'.concat(E[_],'">').concat(_,"</button>")}).join(""),"</p>"),n={CUSTOM_SCOPE_GROUP_NAME:"Audacy-Traffic-Manager",INSTANT_LEARNING_TYPE:"iL",MODEL:"claude-3.5-sonnet",CONFIG_MASTER_NAME:"audacy-config",SCOPE_NAME:"Custom",ASSISTANT_NAME:process.env.VITE_AUDACY_RULE_ASSISTANT||"testaudacyrilprompt",ORGANIZATION_NAME:"techolution",BASE_URL:e.VITE_LLM_STUDIO_URL,BASE_WEBSOCKET_URL:e.VITE_LLM_STUDIO_WEBSOCKET_URL,CHAT_TITLE:"Teach Me OTJ - <scope> - Add Learning",CHAT_TITLE_EDIT:"Teach Me OTJ - <scope> - Edit Learning",FORM_TITLE:"Learning Details",INITIAL_CHAT_MESSAGE:T,CATEGORY:"Global-Template",SOCKET_TIMEOUT:24e4};export{n as IL_CONFIG_CONSTANTS,e as config};
|
|
2
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThinkingBulbIcon.gif.js","sources":["../../../../src/features/LearningManagement/public/ThinkingBulbIcon.gif"],"sourcesContent":["export default \"6fbbe065ef78c384.gif\""],"names":["ThinkingBulb"],"mappings":"AAAA,IAAeA,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as t}from"tslib";import{create as n}from"zustand";import{getQueryParam as r,setQueryParams as u,QUERY_PARAM_KEYS as o}from"../hooks/useLearningTemplateQueryParams.js";var i={globalRuleSet:[],genreRuleSet:[],customRuleSet:[]},a=n(function(n){return{sidebarTab:"rule-sets",selectedRuleSetId:null,ruleSets:i,isStationModalOpen:!1,isILModalTriggered:"true"===r(o.OPEN_IL),isStationOnboardModalTriggered:"true"===r(o.ONBOARD_STATION),scopeTreeData:null,stations:[],selectedStationId:null,currentRules:[],createdVariantInfo:null,setRuleSets:function(e){return n({ruleSets:e})},setScopeTreeData:function(e){return n({scopeTreeData:e})},setStationModalOpen:function(e){return n({isStationModalOpen:e})},setIsILModalTriggered:function(e){var t;u(((t={})[o.OPEN_IL]=e?"true":null,t)),n({isILModalTriggered:e})},setIsStationOnboardModalTriggered:function(e){var t;u(((t={})[o.ONBOARD_STATION]=e?"true":null,t)),n({isStationOnboardModalTriggered:e})},setInitialRules:function(e){return n({currentRules:e})},setCreatedVariantInfo:function(e){return n({createdVariantInfo:e})},resetCreatedVariantInfo:function(){return n({createdVariantInfo:null})},setSelectedRuleSetId:function(e){var t;u(((t={})[o.RULESET_ID]=e,t)),n({selectedRuleSetId:e})},toggleRuleTier:function(t){return n(function(n){return{currentRules:n.currentRules.map(function(n){return n.id===t?e(e({},n),{isOpen:!n.isOpen}):n})}})},deleteRule:function(t,r){return n(function(n){return{currentRules:n.currentRules.map(function(n){return n.id===t?e(e({},n),{rules:n.rules.filter(function(e){return e.id!==r}),ruleCount:n.ruleCount-1}):n})}})},setStations:function(e){return n({stations:e})},addStation:function(e){return n(function(n){return{stations:t(t([],n.stations,!0),[e],!1)}})},deleteStation:function(e){return n(function(t){return{stations:t.stations.filter(function(t){return t.stationId!==e}),selectedStationId:t.selectedStationId===e?null:t.selectedStationId}})},error:null,setError:function(e){return n({error:e})},tiers:[],setTiers:function(e){return n({tiers:e})}}});export{i as INITIAL_RULE_SETS,a as useLearningTemplateStore};
|
|
1
|
+
import{__assign as e,__spreadArray as t}from"tslib";import{create as n}from"zustand";import{getQueryParam as r,setQueryParams as u,QUERY_PARAM_KEYS as o}from"../hooks/useLearningTemplateQueryParams.js";var i={globalRuleSet:[],genreRuleSet:[],customRuleSet:[]},a=n(function(n){return{sidebarTab:"rule-sets",selectedRuleSetId:null,ruleSets:i,isStationModalOpen:!1,isILModalTriggered:"true"===r(o.OPEN_IL),isStationOnboardModalTriggered:"true"===r(o.ONBOARD_STATION),scopeTreeData:null,stations:[],selectedStationId:null,currentRules:[],createdVariantInfo:null,templateMap:{},setTemplateData:function(t,r){return n(function(n){var u;return{templateMap:e(e({},n.templateMap),(u={},u[t]=r,u))}})},setRuleSets:function(e){return n({ruleSets:e})},setScopeTreeData:function(e){return n({scopeTreeData:e})},setStationModalOpen:function(e){return n({isStationModalOpen:e})},setIsILModalTriggered:function(e){var t;u(((t={})[o.OPEN_IL]=e?"true":null,t)),n({isILModalTriggered:e})},setIsStationOnboardModalTriggered:function(e){var t;u(((t={})[o.ONBOARD_STATION]=e?"true":null,t)),n({isStationOnboardModalTriggered:e})},setInitialRules:function(e){return n({currentRules:e})},setCreatedVariantInfo:function(e){return n({createdVariantInfo:e})},resetCreatedVariantInfo:function(){return n({createdVariantInfo:null})},setSelectedRuleSetId:function(e){var t;u(((t={})[o.RULESET_ID]=e,t)),n({selectedRuleSetId:e})},toggleRuleTier:function(t){return n(function(n){return{currentRules:n.currentRules.map(function(n){return n.id===t?e(e({},n),{isOpen:!n.isOpen}):n})}})},deleteRule:function(t,r){return n(function(n){return{currentRules:n.currentRules.map(function(n){return n.id===t?e(e({},n),{rules:n.rules.filter(function(e){return e.id!==r}),ruleCount:n.ruleCount-1}):n})}})},setStations:function(e){return n({stations:e})},addStation:function(e){return n(function(n){return{stations:t(t([],n.stations,!0),[e],!1)}})},deleteStation:function(e){return n(function(t){return{stations:t.stations.filter(function(t){return t.stationId!==e}),selectedStationId:t.selectedStationId===e?null:t.selectedStationId}})},error:null,setError:function(e){return n({error:e})},tiers:[],setTiers:function(e){return n({tiers:e})}}});export{i as INITIAL_RULE_SETS,a as useLearningTemplateStore};
|
|
2
2
|
//# sourceMappingURL=useLearningTemplateStore.js.map
|