@e-llm-studio/instant-learning 0.1.1-alpha.65 → 0.1.1-alpha.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),S=require("./store/useEnvStore.js"),m=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),h=require("./components/CreateRuleSetLegacyModal.js"),_=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],w=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],A=new Set(E.map(function(e){return e.id}));exports.default=function(r){var R,I=this,O=r.userDetails,q=r.llmStudioUrl,P=r.audacyBackendUrl,k=r.ilLabels,D=r.config,N=r.rbacConfig,x=r.app_integration_id,U=r.backwardCompatibility,B=void 0!==U&&U,G=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),M=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.error}),Q=s.useLearningTemplateStore(function(e){return e.setError}),Y=s.useLearningTemplateStore(function(e){return e.setStations}),K=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),H=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),V=n.useState({isOpen:!1,type:"GLOBAL"}),W=V[0],z=V[1],J=n.useState(!1),X=J[0],Z=J[1],$=n.useState(!1),ee=$[0],te=$[1],ne=n.useState("learnings"),re=ne[0],se=ne[1],ae=n.useState(null),ie=ae[0],oe=ae[1],le=n.useState(null),ue=le[0],ce=le[1],de=n.useRef(null),pe=n.useRef(null),fe=n.useRef(null),ge=u.default();ge.user;var Se=ge.setUser,me=m.useConfigStore(),ve=me.setConfig,he=me.setIlLabels,_e=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&A.has(n)?n:"learnings";(null==t?void 0:t.length)&&M&&se&&(M(t),se(r))},[null==_e?void 0:_e.search,se,M]);var ye=_.usePermissionsStore(function(e){return e.fetchPermissions}),Te=_.usePermissionsStore(function(e){return e.hasPermission}),be=y.useAppSecRolesStore(function(e){return e.setRoles}),Ce=S.default(function(e){return e.appsecRbacUrl})===N.appsecRbacUrl,Le=T.useGetAppSecRolesQuery(N.applicationId,Ce).data;n.useEffect(function(){Le&&be(Le.map(function(e){return{_id:e._id,name:e.name}}))},[Le,be]),n.useEffect(function(){var e;console.log("userDetails",O),Se(O),console.log("llmStudioUrl",q),console.log("audacyBackendUrl",P),S.default.getState().setLlmStudioUrl(q),S.default.getState().setAudacyBackendUrl(P),S.default.getState().setRbacConfig(N),ve(D),he(k),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=x?x:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(B),s.useLearningTemplateStore.getState().setToken(null!==(e=O.accessToken)&&void 0!==e?e:null)},[O,Se,q,P,N,D,ve,k,he,x,B]),n.useEffect(function(){(null==O?void 0:O.accessToken)&&q&&c.fetchTiers()},[x,null==O?void 0:O.accessToken,q]);var je=function(t){return void 0===t&&(t=!0),e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&Z(!0),Q(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,ye(N.applicationId)];case 2:return u.sent(),n=function(t){if(!_.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(x,O.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(oe(null),H({data:i}),pe.current?(M(pe.current),se("learnings"),pe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||M(i.id)):(oe(null!==(l=a.id)&&void 0!==l?l:null),H(null)):(oe(null),H(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Q("Failed to load data. Please try again later."),[3,6];case 5:return Z(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==O?void 0:O.accessToken)||void 0===e?void 0:e.length)&&Ce?je(!0):console.warn("Error: Trying to fetch rules without access token",O)},[null==O?void 0:O.accessToken,Q,Y,N.applicationId,Ce]);var Ee=function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o,l,u,d,p,f,S;return e.__generator(this,function(m){switch(m.label){case 0:te(!0),m.label=1;case 1:return m.trys.push([1,8,9,10]),[4,c.deleteRuleSet(t,O.accessToken)];case 2:if(m.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(a=s.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==a?void 0:a.data)||null,t))&&i.length>1&&(o=i[i.length-2],M(o),se("learnings"))),!r||!n)return[3,6];m.label=3;case 3:return m.trys.push([3,5,,6]),[4,c.updateStation({station_name:n,ruleset_id:""})];case 4:return m.sent(),[3,6];case 5:return l=m.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,je(!0)];case 7:return m.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=fe.current)||void 0===d||d.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return u=m.sent(),console.error("An error occurred during scope deletion.",u),null===(p=fe.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(S=null===(f=null==u?void 0:u.response)||void 0===f?void 0:f.data)||void 0===S?void 0:S.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return te(!1),[7];case 10:return[2]}})})},we=K,Ae=ue?{data:{id:ue.stationId,name:ue.stationName,type:"STATION",metrics:{learningsCount:ue.learningsCount,stationsCount:0},children:[]}}:we,Re=!!(null==Ae?void 0:Ae.data);null===(R=null==Ae?void 0:Ae.data)||void 0===R||R.type;var Ie=_.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",N.applicationResourceId||""),Oe=(ue?E.filter(function(e){return"stations"!==e.id}):E).filter(function(e){return!(!B&&"access"===e.id)});return t.jsx(v.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:X?t.jsx(f.default,{}):F?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:F})),t.jsx("button",e.__assign({onClick:function(){return je(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Re?t.jsx(o.default,{onOpenCreateModal:function(){return z({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return z({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return z({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Ee(t,n,o)];case 1:return e.sent(),[3,3];case 2:z({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Te("ilotj.scope.delete",e)},canEditScope:function(e){return Te("ilotj.scope.edit",e)},canCreateScope:function(e){return Te("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),se(t),M(e)},activeSectionId:re,scopeTreeData:Ae,sectionsConfig:Oe,onViewStation:function(e){de.current=G,ce(e),se("learnings"),M(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(pe.current=t),je(e)},nodeTypesConfig:w,app_integration_id:x,token:O.accessToken}):t.jsx(l.default,{onCreate:function(){return z({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:Ie,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||ie))return null===(l=fe.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=fe.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=fe.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:fe}),B&&W.isOpen&&"DELETE"!==W.type&&"RENAME"!==W.type?t.jsx(h.default,{isOpen:!0,onClose:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,S,m,v,h,_,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:te(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===W.type&&W.parentId,o=i?"genreRuleSet":W.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:W.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:x}),[4,c.createRuleSet(r,O.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(pe.current=u,d=n&&(null===(h=r.topic)||void 0===h?void 0:h.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==W.type&&W.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(_=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===_?void 0:_.data)||void 0===y?void 0:y.id:W.parentId))return[3,10];if(!B)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:x||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return S=L.sent(),console.error("Failed to inherit rules for the new scope:",S),[3,10];case 10:return[4,je(!0)];case 11:return L.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw m=L.sent(),console.error("An error occurred during scope creation.",m),null===(T=fe.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==m?void 0:m.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),m;case 13:return te(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Re,canCreateGlobal:Ie}):t.jsx(b.default,{isOpen:W.isOpen&&"DELETE"!==W.type,onClose:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onCreate:function(t){return n=null!=t?t:"",e.__awaiter(I,void 0,void 0,function(){var t,r,s,a;return e.__generator(this,function(i){switch(i.label){case 0:te(!0),i.label=1;case 1:return i.trys.push([1,4,5,6]),W.scopeId?[4,c.renameScope({scope_id:W.scopeId,scope_name:n})]:[2];case 2:return i.sent(),[4,je(!0)];case 3:return i.sent(),z(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw t=i.sent(),console.error("An error occurred during scope rename.",t),null===(r=fe.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),t;case 5:return te(!1),[7];case 6:return[2]}})});var n},hasGlobalRuleSet:Re}),t.jsx(p.default,{isOpen:W.isOpen&&"DELETE"===W.type,onCancel:function(){return z(e.__assign(e.__assign({},W),{isOpen:!1}))},onConfirm:function(){return Ee(W.scopeId,W.initialName,W.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:W.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ee})]}))})};
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"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),f=require("./components/LearningTemplateManagementSkeleton.js"),g=require("./utils/treeUtils.js"),m=require("./store/useEnvStore.js"),S=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),h=require("./components/CreateRuleSetLegacyModal.js"),_=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./RuleContent/AddScopeModal.js"),C=require("react-router-dom"),L=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),E=require("./RuleContent/RenameScopeModal.js"),R=[{id:"learnings",label:"Learnings",icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:r.Users}],A=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],w=new Set(R.map(function(e){return e.id}));exports.default=function(r){var O,I=this,q=r.userDetails,N=r.llmStudioUrl,P=r.audacyBackendUrl,k=r.ilLabels,x=r.config,D=r.rbacConfig,U=r.app_integration_id,M=r.backwardCompatibility,B=void 0!==M&&M,G=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),F=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),Q=s.useLearningTemplateStore(function(e){return e.error}),Y=s.useLearningTemplateStore(function(e){return e.setError}),K=s.useLearningTemplateStore(function(e){return e.setStations}),H=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),V=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),W=n.useState({isOpen:!1,type:"GLOBAL"}),z=W[0],J=W[1],X=n.useState(!1),Z=X[0],$=X[1],ee=n.useState(!1),te=ee[0],ne=ee[1],re=n.useState("learnings"),se=re[0],ae=re[1],ie=n.useState(null),oe=ie[0],le=ie[1],ue=n.useState(null),ce=ue[0],de=ue[1],pe=n.useRef(null),fe=n.useRef(null),ge=n.useRef(null),me=u.default();me.user;var Se=me.setUser,ve=S.useConfigStore(),he=ve.setConfig,_e=ve.setIlLabels,ye=function(){try{return C.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&w.has(n)?n:"learnings";(null==t?void 0:t.length)&&F&&ae&&(F(t),ae(r))},[null==ye?void 0:ye.search,ae,F]);var Te=_.usePermissionsStore(function(e){return e.fetchPermissions}),be=_.usePermissionsStore(function(e){return e.hasPermission}),Ce=y.useAppSecRolesStore(function(e){return e.setRoles}),Le=m.default(function(e){return e.appsecRbacUrl})===D.appsecRbacUrl,je=T.useGetAppSecRolesQuery(D.applicationId,Le).data;n.useEffect(function(){je&&Ce(je.map(function(e){return{_id:e._id,name:e.name}}))},[je,Ce]),n.useEffect(function(){var e;console.log("userDetails",q),Se(q),console.log("llmStudioUrl",N),console.log("audacyBackendUrl",P),m.default.getState().setLlmStudioUrl(N),m.default.getState().setAudacyBackendUrl(P),m.default.getState().setRbacConfig(D),he(x),_e(k),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=U?U:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(B),s.useLearningTemplateStore.getState().setToken(null!==(e=q.accessToken)&&void 0!==e?e:null)},[q,Se,N,P,D,x,he,k,_e,U,B]),n.useEffect(function(){(null==q?void 0:q.accessToken)&&N&&c.fetchTiers()},[U,null==q?void 0:q.accessToken,N]);var Ee=function(t){return void 0===t&&(t=!0),e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&$(!0),Y(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,Te(D.applicationId)];case 2:return u.sent(),n=function(t){if(!_.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(U,q.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(le(null),V({data:i}),fe.current?(F(fe.current),ae("learnings"),fe.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||F(i.id)):(le(null!==(l=a.id)&&void 0!==l?l:null),V(null)):(le(null),V(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),Y("Failed to load data. Please try again later."),[3,6];case 5:return $(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==q?void 0:q.accessToken)||void 0===e?void 0:e.length)&&Le?Ee(!0):console.warn("Error: Trying to fetch rules without access token",q)},[null==q?void 0:q.accessToken,Y,K,D.applicationId,Le]);var Re=function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,s,a;return e.__generator(this,function(i){switch(i.label){case 0:ne(!0),i.label=1;case 1:return i.trys.push([1,4,5,6]),z.scopeId?[4,c.renameScope({scope_id:z.scopeId,scope_name:t})]:[2];case 2:return i.sent(),[4,Ee(!0)];case 3:return i.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw n=i.sent(),console.error("An error occurred during scope rename.",n),null===(r=ge.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==n?void 0:n.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),n;case 5:return ne(!1),[7];case 6:return[2]}})})},Ae=function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o,l,u,d,p,f,m;return e.__generator(this,function(S){switch(S.label){case 0:ne(!0),S.label=1;case 1:return S.trys.push([1,8,9,10]),[4,c.deleteRuleSet(t,q.accessToken)];case 2:if(S.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(a=s.useLearningTemplateStore.getState().scopeTreeData,(i=g.findNodePathById((null==a?void 0:a.data)||null,t))&&i.length>1&&(o=i[i.length-2],F(o),ae("learnings"))),!r||!n)return[3,6];S.label=3;case 3:return S.trys.push([3,5,,6]),[4,c.updateStation({station_name:n,ruleset_id:""})];case 4:return S.sent(),[3,6];case 5:return l=S.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,Ee(!0)];case 7:return S.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(d=ge.current)||void 0===d||d.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return u=S.sent(),console.error("An error occurred during scope deletion.",u),null===(p=ge.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(m=null===(f=null==u?void 0:u.response)||void 0===f?void 0:f.data)||void 0===m?void 0:m.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return ne(!1),[7];case 10:return[2]}})})},we=H,Oe=ce?{data:{id:ce.stationId,name:ce.stationName,type:"STATION",metrics:{learningsCount:ce.learningsCount,stationsCount:0},children:[]}}:we,Ie=!!(null==Oe?void 0:Oe.data);null===(O=null==Oe?void 0:Oe.data)||void 0===O||O.type;var qe=_.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",D.applicationResourceId||""),Ne=(ce?R.filter(function(e){return"stations"!==e.id}):R).filter(function(e){return!(!B&&"access"===e.id)});return t.jsx(v.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:Z?t.jsx(f.default,{}):Q?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:Q})),t.jsx("button",e.__assign({onClick:function(){return Ee(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ie?t.jsx(o.default,{onOpenCreateModal:function(){return J({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return J({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return J({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(I,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=g.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Ae(t,n,o)];case 1:return e.sent(),[3,3];case 2:J({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return be("ilotj.scope.delete",e)},canEditScope:function(e){return be("ilotj.scope.edit",e)},canCreateScope:function(e){return be("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n)),ae(t),F(e)},activeSectionId:se,scopeTreeData:Oe,sectionsConfig:Ne,onViewStation:function(e){pe.current=G,de(e),ae("learnings"),F(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(fe.current=t),Ee(e)},nodeTypesConfig:A,app_integration_id:U,token:q.accessToken}):t.jsx(l.default,{onCreate:function(){return J({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:qe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,o,l,u,d,p,f;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||oe))return null===(l=ge.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=ge.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(L.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=ge.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(f=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===f?void 0:f.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:ge}),B&&z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type?t.jsx(h.default,{isOpen:!0,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(I,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,f,g,m,S,v,h,_,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:ne(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===z.type&&z.parentId,o=i?"genreRuleSet":z.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:z.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:U}),[4,c.createRuleSet(r,q.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(fe.current=u,d=n&&(null===(h=r.topic)||void 0===h?void 0:h.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==z.type&&z.parentId,!d&&!p)return[3,10];if(!(f=n?null===(y=null===(_=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===_?void 0:_.data)||void 0===y?void 0:y.id:z.parentId))return[3,10];if(!B)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:f,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return g=L.sent(),console.error("Failed to inherit rules for the new scope:",g),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:f,target_scope_id:u,application_mapping_id:U||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return m=L.sent(),console.error("Failed to inherit rules for the new scope:",m),[3,10];case 10:return[4,Ee(!0)];case 11:return L.sent(),J(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw S=L.sent(),console.error("An error occurred during scope creation.",S),null===(T=ge.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==S?void 0:S.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),S;case 13:return ne(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ie,canCreateGlobal:qe}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:z.isOpen&&"DELETE"!==z.type&&"RENAME"!==z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onCreate:function(e){return Re(null!=e?e:"")},hasGlobalRuleSet:Ie}),t.jsx(E.default,{isOpen:z.isOpen&&"RENAME"===z.type,onClose:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onSave:Re,initialName:z.initialName})]}),t.jsx(p.default,{isOpen:z.isOpen&&"DELETE"===z.type,onCancel:function(){return J(e.__assign(e.__assign({},z),{isOpen:!1}))},onConfirm:function(){return Ae(z.scopeId,z.initialName,z.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:z.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:te})]}))})};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),i=require("lucide-react");exports.default=function(r){var o=r.isOpen,s=r.onClose,a=r.onSave,l=r.initialName,c=void 0===l?"":l,d=t.useState(c),u=d[0],p=d[1],x=t.useState(""),f=x[0],g=x[1],b=t.useState(!1),y=b[0],_=b[1],h=t.useRef(null);if(t.useEffect(function(){o&&(p(c),g(""),setTimeout(function(){var e,n;null===(e=h.current)||void 0===e||e.focus(),null===(n=h.current)||void 0===n||n.select()},50))},[o,c]),!o)return null;var v=function(){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){switch(e.label){case 0:if(!u.trim())return g("Scope Name is required"),[2];g(""),_(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a(u.trim())];case 2:return e.sent(),s(),[3,5];case 3:return e.sent(),g("Failed to rename scope. Please try again."),[3,5];case 4:return _(!1),[7];case 5:return[2]}})})};return n.jsx("div",e.__assign({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&s()}},{children:n.jsxs("div",e.__assign({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[n.jsx("span",e.__assign({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),n.jsx("button",e.__assign({onClick:s,disabled:y,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:n.jsx(i.X,{size:20})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[n.jsxs("label",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),n.jsx("input",{ref:h,type:"text",value:u,onChange:function(e){p(e.target.value),f&&g("")},onKeyDown:function(e){"Enter"===e.key&&v(),"Escape"===e.key&&s()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(f?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),f&&n.jsx("p",e.__assign({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:f}))]})),n.jsxs("div",e.__assign({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[n.jsx("button",e.__assign({onClick:s,disabled:y,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.6:1}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:v,disabled:y,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:y?"not-allowed":"pointer",opacity:y?.7:1}},{children:y?"Saving...":"Save"}))]}))]}))}))};
2
+ //# sourceMappingURL=RenameScopeModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenameScopeModal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material"),o=require("lucide-react"),i=require("primereact/toast"),s=require("uuid"),a=require("../../apis/scopeApis.js"),l=require("./StationAutocomplete.js"),u=require("../CardSkeleton.js"),c=require("./OnboardingLoader.js"),d=require("./TemplateCard.js"),p=require("../../styles/StationOnboardModal.module.css.js"),g=require("./InputField.js"),x=require("../../store/useAuthStore.js"),f=require("../../store/useConfigStore.js"),m=require("../../store/useLearningTemplateStore.js"),h=require("../../config.js"),_=[{label:"PT - Pacific Time",value:"Pacific Time"},{label:"MT - Mountain Time",value:"Mountain Time"},{label:"CT - Central Time",value:"Central Time"},{label:"ET - Eastern Time",value:"Eastern Time"}],S=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],b=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],v=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}];exports.default=function(y){var j,C=y.isOpen,T=y.onClose,w=y.onBoardStation,F=y.app_integration_id,B=y.token,E=r.useState(null),O=E[0],k=E[1],z=r.useState([]),N=z[0],D=z[1],R=r.useState(0),q=R[0],I=R[1],A=r.useState(!0),M=A[0],L=A[1],P=r.useState(!1),W=P[0],G=P[1],U=r.useState([]),Y=U[0],H=U[1],X=r.useState(""),Z=X[0],K=X[1],J=r.useState(""),Q=J[0],V=J[1],$=r.useState(!1),ee=$[0],ne=$[1],re=r.useState(!1),te=re[0],oe=re[1],ie=r.useState(null),se=ie[0],ae=ie[1],le=r.useState(null);le[0],le[1];var ue=r.useState(!1),ce=ue[0],de=ue[1],pe=r.useState(0),ge=pe[0],xe=pe[1],fe=r.useState(""),me=fe[0],he=fe[1],_e=x.default().user,Se=r.useRef(null),be=r.useRef(null),ve=r.useRef(null),ye=r.useRef(null);f.useConfigStore().configuration;var je=r.useState({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),Ce=je[0],Te=je[1],we=function(e,n){return e.find(function(e){return e.value===n})||null},Fe=r.useMemo(function(){return N.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[N]),Be=r.useMemo(function(){var e,n,r;if(!Ce.genre)return null;var t=N.find(function(e){return e.scope_name===Ce.genre});return t?{id:t.id,title:t.scope_name||"Unnamed Template",description:(null===(e=t.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(n=t.inheritance)||void 0===n?void 0:n[0])||void 0,rulesCount:t.rules_count||0,tiersCount:t.tier_count||0,isCopy:null!==(r=t.is_copy)&&void 0!==r&&r}:null},[Ce.genre,N]);r.useEffect(function(){return function(){ve.current&&clearTimeout(ve.current)}},[]);var Ee=function(n){return e.__awaiter(void 0,void 0,void 0,function(){var r,t,o;return e.__generator(this,function(i){switch(i.label){case 0:if(W)return[2];G(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,a.retrieveGenreScopes({limit:"20",offset:String(n)})];case 2:return"success"===(null==(r=i.sent())?void 0:r.status)&&Array.isArray(null==r?void 0:r.data)?(t=r.data,D(function(r){if(0===n)return t;var o=new Set(r.map(function(e){return e.id})),i=t.filter(function(e){return!o.has(e.id)});return e.__spreadArray(e.__spreadArray([],r,!0),i,!0)}),t.length<20?L(!1):L(!0),I(n+20)):L(!1),[3,5];case 3:return o=i.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",o),L(!1),[3,5];case 4:return G(!1),[7];case 5:return[2]}})})};r.useEffect(function(){C&&(D([]),I(0),L(!0),Ee(0))},[C]);r.useEffect(function(){Te(O?function(n){var r;return e.__assign(e.__assign({},n),{region:null!==(r=O.market)&&void 0!==r?r:""})}:{region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""})},[O]),r.useEffect(function(){var e=setTimeout(function(){V(Z)},500);return function(){return clearTimeout(e)}},[Z]),r.useEffect(function(){e.__awaiter(void 0,void 0,void 0,function(){var n,r,t,o;return e.__generator(this,function(e){switch(e.label){case 0:if(!Q.trim())return H([]),[2];ne(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.searchScopes({search_string:Q})];case 2:return"success"===(null==(n=e.sent())?void 0:n.status)&&Array.isArray(null==n?void 0:n.data)?(r=n.data.filter(function(e){var n,r=null!==(n=e.inheritance)&&void 0!==n?n:[],t=r.indexOf(e.scope_name);return!(t<=0)&&r[t-1]===Ce.genre}),t=r.map(function(e){var n,r,t;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(n=e.description)||void 0===n?void 0:n.trim())||"No description available.",inheritedText:(null===(r=e.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(t=e.is_copy)&&void 0!==t&&t}}),H(t)):H([]),[3,5];case 3:return o=e.sent(),console.error("[StationOnboard] Error searching scopes:",o),H([]),[3,5];case 4:return ne(!1),[7];case 5:return[2]}})})},[Q,Ce.genre]),r.useEffect(function(){!Q.trim()&&Be&&ae(Be.id)},[Q,Be]);var Oe=function(){setTimeout(function(){ye.current&&ye.current.scrollTo({top:ye.current.scrollHeight,behavior:"smooth"})},100)},ke=function(){he(""),k(null),Te({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),H([]),K(""),ae(null),T()},ze=function(n,r){var t;if("primeTime"!==n){var o=null!==(t=null==r?void 0:r.value)&&void 0!==t?t:"";Te(function(r){var t;return e.__assign(e.__assign({},r),((t={})[n]=String(o),t))}),"genre"===n&&(oe(!0),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(function(){var e=N.find(function(e){return e.scope_name===o});ae(e?e.id:null),oe(!1)},800))}else{var i=(null==r?void 0:r.value)?String(r.value):"";Te(function(n){return e.__assign(e.__assign({},n),{primeTime:i?[i]:[]})})}},Ne=Boolean(O&&Ce.region&&Ce.timezone&&Ce.primeTime.length>0&&Ce.genre);return n.jsxs(t.Dialog,e.__assign({open:C,onClose:ke,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[n.jsx(i.Toast,{ref:Se}),n.jsxs(t.Box,e.__assign({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),n.jsx(t.IconButton,e.__assign({onClick:ke,disabled:ce,sx:{color:"#19213D"}},{children:n.jsx(o.X,{size:24})}))]})),n.jsxs(t.DialogContent,e.__assign({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[n.jsx(c.default,{isLoading:ce,currentStep:ge,onComplete:function(){de(!1);var e=be.current;ke(),w(e||void 0),be.current=null}}),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flex:1,paddingY:"14px",paddingX:"20px",gap:3,overflowY:"hidden"}},{children:[n.jsxs(t.Box,e.__assign({ref:ye,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5",height:"100%",overflowY:"auto"}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[n.jsxs(t.Box,e.__assign({className:p.default.formGroup},{children:[n.jsxs("label",e.__assign({className:p.default.label},{children:[n.jsx("span",e.__assign({className:p.default.asterisk},{children:"*"})),"Station Name/Call Letters"]})),n.jsx(l.default,{value:me,onChange:he,onStationSelect:function(e){return k(e)}})]})),n.jsx(g.default,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:Ce.region||void 0,isSearchable:!1}),n.jsx(g.default,{required:!0,label:"TimeZone",placeholder:"Select TimeZone",options:_,value:we(_,Ce.timezone),onOptionChange:function(e){return ze("timezone",e)},isSearchable:!1}),n.jsx(g.default,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:S,value:we(S,(null===(j=Ce.primeTime)||void 0===j?void 0:j[0])||""),onOptionChange:function(e){return ze("primeTime",e)},isSearchable:!1}),n.jsx(t.Box,e.__assign({onClick:Oe,sx:{width:"100%"}},{children:n.jsx(g.default,{label:"Station Type",placeholder:"None",options:b,value:we(b,Ce.type),onOptionChange:function(n){ze("type",n),"Low Sellout"!==(null==n?void 0:n.value)&&Te(function(n){return e.__assign(e.__assign({},n),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===Ce.type&&n.jsx(t.Box,e.__assign({onClick:Oe,sx:{width:"100%"}},{children:n.jsx(g.default,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:v,value:we(v,Ce.lowSelloutConfig),onOptionChange:function(e){return ze("lowSelloutConfig",e)},isSearchable:!1})}))]}))]})),n.jsxs(t.Box,e.__assign({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column",height:"100%",overflowY:"auto"}},{children:[n.jsxs(t.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),n.jsx(t.Box,e.__assign({sx:{mb:2}},{children:n.jsx(g.default,{required:!0,label:"",placeholder:"Select Genre",options:Fe,value:we(Fe,Ce.genre),onOptionChange:function(e){return ze("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!W&&M&&Ee(q)},isLoadingOptions:W,hasMoreOptions:M})})),n.jsx(t.Box,e.__assign({sx:{mb:3}},{children:te?n.jsx(u.default,{}):Be?n.jsxs(t.Box,e.__assign({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[n.jsx(t.Box,e.__assign({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:n.jsxs("svg",e.__assign({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[n.jsx("circle",{cx:"12",cy:"12",r:"2"}),n.jsx("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),n.jsxs(t.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[n.jsx(t.Typography,e.__assign({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:Be.title})),n.jsx(t.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:Be.description})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[Be.inheritedText&&n.jsxs(t.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[n.jsxs("svg",e.__assign({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("path",{d:"M21 3L9 15"}),n.jsx("path",{d:"M3 21l6-6"})]})),Be.inheritedText]})),n.jsxs(t.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Be.rulesCount," rules"]})),n.jsxs(t.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Be.tiersCount," Tiers"]}))]}))]}))]})):Ce.genre?null:n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:[n.jsx(o.Brush,{size:28}),n.jsx(t.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))]}))})),Ce.genre&&n.jsxs(n.Fragment,{children:[n.jsxs(t.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",Ce.genre,"” Scope"," ",n.jsx(t.Typography,e.__assign({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),n.jsxs(t.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",Ce.genre,"” category to copy its learnings."]})),n.jsxs("div",e.__assign({className:p.default.searchWrapper,style:{marginBottom:"12px"}},{children:[n.jsx("input",{type:"text",value:Z,onChange:function(e){return K(e.target.value)},placeholder:"Search for station...",className:p.default.searchInput}),n.jsx(o.Search,{className:p.default.searchIcon,size:16})]})),n.jsxs(t.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[ee&&n.jsx(u.default,{}),!ee&&0===Y.length&&Q.trim()&&n.jsxs(t.Typography,e.__assign({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',Q,'".']})),!ee&&Y.map(function(r){return n.jsx(d.default,e.__assign({},r,{isSelected:se===r.id,onSelect:function(e){var n;ae(se===e?null!==(n=null==Be?void 0:Be.id)&&void 0!==n?n:null:e)}}),r.id)})]}))]})]}))]}))]})),n.jsxs(t.Box,e.__assign({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[n.jsx("button",e.__assign({onClick:ke,disabled:ce,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,t,o,i,l,u,c,d,p,g,x,f,_,S,b,v,y,j;return e.__generator(this,function(C){switch(C.label){case 0:if(!O||!se)return console.error("[StationOnboard] Missing required data for onboarding"),[2];n=Be?e.__spreadArray([Be],Y,!0):Y,r=n.find(function(e){return e.id===se}),null==r?void 0:r.isCopy,de(!0),xe(0),t=null,C.label=1;case 1:return C.trys.push([1,3,,4]),u=m.useLearningTemplateStore.getState().backwardCompatibility,o=u?{topic:"customRuleSet",customScopeGroupName:h.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:O.station_name||"New Station",parentScopeId:null,customScopeName:O.station_name||"New Station",customScopeId:s.v4(),createByName:(null==_e?void 0:_e.firstname)||"System",createdBy:(null==_e?void 0:_e.email)||"system@audacy.com",scopeType:"Station"}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:O.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:F},console.log("[StationOnboard] Step 1: Creating rule set with payload:",o),[4,a.createRuleSet(o,B)];case 2:if(i=C.sent(),!(t=null===(_=null==i?void 0:i.data)||void 0===_?void 0:_.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",t),xe(1),[3,4];case 3:return l=C.sent(),console.error("[StationOnboard] Error creating rule set:",l),null===(S=Se.current)||void 0===S||S.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),de(!1),xe(0),[2];case 4:return C.trys.push([4,6,,11]),u=m.useLearningTemplateStore.getState().backwardCompatibility,c=e.__assign(e.__assign({market:O.market,region:O.region},u?{}:{timezone:Ce.timezone}),{primetime_windows:Ce.primeTime,genre:Ce.genre,station_type:""===Ce.type?null:Ce.type,low_sellout_configurations:"Low Sellout"===Ce.type?Ce.lowSelloutConfig:null,ruleset_id:t,station_guid:O.station_guid,station_name:O.station_name||"New Station"}),console.log("[StationOnboard] Step 2: Updating station with payload:",c),[4,a.updateStation(c)];case 5:return C.sent(),console.log("[StationOnboard] Step 2 Complete: Station updated"),xe(2),[3,11];case 6:d=C.sent(),console.error("[StationOnboard] Error updating station, rolling back rule set:",d),409===d.status?(null===(b=Se.current)||void 0===b||b.show({severity:"error",life:2500,summary:"Error updating station",detail:"Station already Onboarded."}),k(null),ae(null),he(""),Te(function(n){return e.__assign(e.__assign({},n),{region:""})})):null===(v=Se.current)||void 0===v||v.show({severity:"error",life:2500,summary:"Error updating station",detail:"Please try again."}),C.label=7;case 7:return C.trys.push([7,9,,10]),[4,a.deleteRuleSet(t,B)];case 8:return C.sent(),console.log("[StationOnboard] Rollback complete: Deleted rule set",t),[3,10];case 9:return p=C.sent(),console.error("[StationOnboard] Failed to rollback rule set deletion:",p),[3,10];case 10:return de(!1),xe(0),[2];case 11:return C.trys.push([11,13,,14]),g=null!==se&&se!==(null==Be?void 0:Be.id),x={source_scope_id:g?se:null!==(y=null==Be?void 0:Be.id)&&void 0!==y?y:se,target_scope_id:t,is_copy_parent_variant_id:g},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",x),[4,a.inheritScopeBackwardCompatible(x)];case 12:return C.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),xe(3),[3,14];case 13:return f=C.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",f),null===(j=Se.current)||void 0===j||j.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),de(!1),xe(0),[2];case 14:return be.current=t,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!Ne||ce,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:Ne?"#2563EB":"#BFDBFE",color:"#fff",cursor:Ne&&!ce?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:ce?n.jsxs(n.Fragment,{children:[n.jsx(t.CircularProgress,{size:16,color:"inherit"}),n.jsx("span",{children:"Onboarding..."})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Onboard Station"}),n.jsx(o.ArrowRight,{size:16})]})}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),i=require("@mui/material"),o=require("lucide-react"),t=require("primereact/toast"),s=require("uuid"),a=require("../../apis/scopeApis.js"),l=require("./StationAutocomplete.js"),u=require("../CardSkeleton.js"),c=require("./OnboardingLoader.js"),d=require("./TemplateCard.js"),p=require("../../styles/StationOnboardModal.module.css.js"),g=require("./InputField.js"),x=require("../../store/useAuthStore.js"),f=require("../../store/useConfigStore.js"),h=require("../../store/useLearningTemplateStore.js"),_=require("../../config.js"),m=require("../../store/useAppSecRolesStore.js"),v=require("../../store/useEnvStore.js"),S=require("../../RuleContent/AddScopeApprovalSearchComponent.js"),y=[{label:"PT - Pacific Time",value:"Pacific Time"},{label:"MT - Mountain Time",value:"Mountain Time"},{label:"CT - Central Time",value:"Central Time"},{label:"ET - Eastern Time",value:"Eastern Time"}],b=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],j=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],C=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}];exports.default=function(w){var T,B=w.isOpen,F=w.onClose,E=w.onBoardStation,k=w.app_integration_id,O=w.token,q=r.useState(null),z=q[0],D=q[1],R=r.useState([]),A=R[0],I=R[1],L=r.useState(0),N=L[0],M=L[1],P=r.useState(!0),W=P[0],G=P[1],U=r.useState(!1),H=U[0],K=U[1],Y=r.useState([]),X=Y[0],Z=Y[1],V=r.useState(""),J=V[0],Q=V[1],$=r.useState(""),ee=$[0],ne=$[1],re=r.useState(!1),ie=re[0],oe=re[1],te=r.useState(!1),se=te[0],ae=te[1],le=r.useState(null),ue=le[0],ce=le[1],de=r.useState(null);de[0],de[1];var pe=r.useState(!1),ge=pe[0],xe=pe[1],fe=r.useState(0),he=fe[0],_e=fe[1],me=r.useState(""),ve=me[0],Se=me[1],ye=x.default().user,be=r.useRef(null),je=r.useRef(null),Ce=r.useRef(null),we=r.useRef(null);f.useConfigStore().configuration;var Te=r.useRef(null),Be=m.useAppSecRolesStore(function(e){return e.roles}),Fe=v.default(function(e){return e.rbacConfig}),Ee=r.useState("approval_required"),ke=Ee[0],Oe=Ee[1],qe=r.useState([]),ze=qe[0],De=qe[1],Re=r.useState([]),Ae=Re[0],Ie=Re[1],Le=r.useState(""),Ne=Le[0],Me=Le[1],Pe=r.useState({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),We=Pe[0],Ge=Pe[1],Ue=function(e,n){return e.find(function(e){return e.value===n})||null},He=r.useMemo(function(){return A.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[A]),Ke=r.useMemo(function(){var e,n,r;if(!We.genre)return null;var i=A.find(function(e){return e.scope_name===We.genre});return i?{id:i.id,title:i.scope_name||"Unnamed Template",description:(null===(e=i.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(n=i.inheritance)||void 0===n?void 0:n[0])||void 0,rulesCount:i.rules_count||0,tiersCount:i.tier_count||0,isCopy:null!==(r=i.is_copy)&&void 0!==r&&r}:null},[We.genre,A]);r.useEffect(function(){return function(){Ce.current&&clearTimeout(Ce.current)}},[]);var Ye=function(n){return e.__awaiter(void 0,void 0,void 0,function(){var r,i,o;return e.__generator(this,function(t){switch(t.label){case 0:if(H)return[2];K(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,a.retrieveGenreScopes({limit:"20",offset:String(n)})];case 2:return"success"===(null==(r=t.sent())?void 0:r.status)&&Array.isArray(null==r?void 0:r.data)?(i=r.data,I(function(r){if(0===n)return i;var o=new Set(r.map(function(e){return e.id})),t=i.filter(function(e){return!o.has(e.id)});return e.__spreadArray(e.__spreadArray([],r,!0),t,!0)}),i.length<20?G(!1):G(!0),M(n+20)):G(!1),[3,5];case 3:return o=t.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",o),G(!1),[3,5];case 4:return K(!1),[7];case 5:return[2]}})})};r.useEffect(function(){B&&(I([]),M(0),G(!0),Ye(0))},[B]);r.useEffect(function(){Ge(z?function(n){var r;return e.__assign(e.__assign({},n),{region:null!==(r=z.market)&&void 0!==r?r:""})}:{region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""})},[z]),r.useEffect(function(){var e=setTimeout(function(){ne(J)},500);return function(){return clearTimeout(e)}},[J]),r.useEffect(function(){e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o;return e.__generator(this,function(e){switch(e.label){case 0:if(!ee.trim())return Z([]),[2];oe(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,a.searchScopes({search_string:ee})];case 2:return"success"===(null==(n=e.sent())?void 0:n.status)&&Array.isArray(null==n?void 0:n.data)?(r=n.data.filter(function(e){var n,r=null!==(n=e.inheritance)&&void 0!==n?n:[],i=r.indexOf(e.scope_name);return!(i<=0)&&r[i-1]===We.genre}),i=r.map(function(e){var n,r,i;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(n=e.description)||void 0===n?void 0:n.trim())||"No description available.",inheritedText:(null===(r=e.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(i=e.is_copy)&&void 0!==i&&i}}),Z(i)):Z([]),[3,5];case 3:return o=e.sent(),console.error("[StationOnboard] Error searching scopes:",o),Z([]),[3,5];case 4:return oe(!1),[7];case 5:return[2]}})})},[ee,We.genre]),r.useEffect(function(){!ee.trim()&&Ke&&ce(Ke.id)},[ee,Ke]);var Xe=function(){setTimeout(function(){we.current&&we.current.scrollTo({top:we.current.scrollHeight,behavior:"smooth"})},100)},Ze=function(){Se(""),D(null),Ge({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),Z([]),Q(""),ce(null),Oe("approval_required"),De([]),Ie([]),Me(""),F()},Ve=function(n,r){var i;if("primeTime"!==n){var o=null!==(i=null==r?void 0:r.value)&&void 0!==i?i:"";Ge(function(r){var i;return e.__assign(e.__assign({},r),((i={})[n]=String(o),i))}),"genre"===n&&(ae(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(function(){var e=A.find(function(e){return e.scope_name===o});ce(e?e.id:null),ae(!1)},800))}else{var t=(null==r?void 0:r.value)?String(r.value):"";Ge(function(n){return e.__assign(e.__assign({},n),{primeTime:t?[t]:[]})})}},Je=Boolean(z&&We.region&&We.timezone&&We.primeTime.length>0&&We.genre);return n.jsxs(i.Dialog,e.__assign({open:B,onClose:Ze,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[n.jsx(t.Toast,{ref:be}),n.jsxs(i.Box,e.__assign({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[n.jsxs(i.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[n.jsx(i.Typography,e.__assign({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),n.jsx(i.Typography,e.__assign({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),n.jsx(i.IconButton,e.__assign({onClick:Ze,disabled:ge,sx:{color:"#19213D"}},{children:n.jsx(o.X,{size:24})}))]})),n.jsxs(i.DialogContent,e.__assign({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[n.jsx(c.default,{isLoading:ge,currentStep:he,onComplete:function(){xe(!1);var e=je.current;Ze(),E(e||void 0),je.current=null}}),n.jsx(i.Box,e.__assign({sx:{display:"flex",flex:1,flexDirection:"column",paddingY:"14px",paddingX:"20px",gap:2,overflowY:"auto"}},{children:n.jsxs(i.Box,e.__assign({sx:{display:"flex",gap:3}},{children:[n.jsxs(i.Box,e.__assign({ref:we,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5"}},{children:[n.jsx(i.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),n.jsxs(i.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[n.jsxs(i.Box,e.__assign({className:p.default.formGroup},{children:[n.jsxs("label",e.__assign({className:p.default.label},{children:[n.jsx("span",e.__assign({className:p.default.asterisk},{children:"*"})),"Station Name/Call Letters"]})),n.jsx(l.default,{value:ve,onChange:Se,onStationSelect:function(e){return D(e)}})]})),n.jsx(g.default,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:We.region||void 0,isSearchable:!1}),n.jsx(g.default,{required:!0,label:"TimeZone",placeholder:"Select TimeZone",options:y,value:Ue(y,We.timezone),onOptionChange:function(e){return Ve("timezone",e)},isSearchable:!1}),n.jsx(g.default,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:b,value:Ue(b,(null===(T=We.primeTime)||void 0===T?void 0:T[0])||""),onOptionChange:function(e){return Ve("primeTime",e)},isSearchable:!1}),n.jsx(i.Box,e.__assign({onClick:Xe,sx:{width:"100%"}},{children:n.jsx(g.default,{label:"Station Type",placeholder:"None",options:j,value:Ue(j,We.type),onOptionChange:function(n){Ve("type",n),"Low Sellout"!==(null==n?void 0:n.value)&&Ge(function(n){return e.__assign(e.__assign({},n),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===We.type&&n.jsx(i.Box,e.__assign({onClick:Xe,sx:{width:"100%"}},{children:n.jsx(g.default,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:C,value:Ue(C,We.lowSelloutConfig),onOptionChange:function(e){return Ve("lowSelloutConfig",e)},isSearchable:!1})})),h.useLearningTemplateStore.getState().backwardCompatibility&&n.jsxs("div",e.__assign({ref:Te,style:{display:"flex",flexDirection:"column",marginTop:"12px"}},{children:[n.jsx(i.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Approval Settings"})),n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Configure who can approve learnings before they get published."})),n.jsxs("div",e.__assign({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"16px"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"12px"}},{children:[n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===ke,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px",marginBottom:"8px"},onClick:function(){return Oe("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Oe("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===ke?"#2563EB":"#CBD5E1")}},{children:"approval_required"===ke&&n.jsx("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),n.jsxs("div",e.__assign({style:{gap:"16px"}},{children:["approval_required"===ke&&n.jsx(S.default,{selectedApprovers:ze,selectedGroupOfApprovers:Ae,onApproversChange:function(e){De(e),Me("")},onGroupsChange:function(e){Ie(e),Me("")}}),Ne&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#8F2C23"}},{children:Ne}))]}))]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===ke,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px"},onClick:function(){Oe("publish_without"),Me("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Oe("publish_without"),Me(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===ke?"#2563EB":"#CBD5E1")}},{children:"publish_without"===ke&&n.jsx("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]}))]}))]}))]})),n.jsxs(i.Box,e.__assign({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column"}},{children:[n.jsxs(i.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),n.jsx(i.Box,e.__assign({sx:{mb:2}},{children:n.jsx(g.default,{required:!0,label:"",placeholder:"Select Genre",options:He,value:Ue(He,We.genre),onOptionChange:function(e){return Ve("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!H&&W&&Ye(N)},isLoadingOptions:H,hasMoreOptions:W})})),n.jsx(i.Box,e.__assign({sx:{mb:3}},{children:se?n.jsx(u.default,{}):Ke?n.jsxs(i.Box,e.__assign({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[n.jsx(i.Box,e.__assign({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:n.jsxs("svg",e.__assign({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[n.jsx("circle",{cx:"12",cy:"12",r:"2"}),n.jsx("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),n.jsxs(i.Box,e.__assign({sx:{flex:1,minWidth:0}},{children:[n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:Ke.title})),n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:Ke.description})),n.jsxs(i.Box,e.__assign({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[Ke.inheritedText&&n.jsxs(i.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[n.jsxs("svg",e.__assign({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("path",{d:"M21 3L9 15"}),n.jsx("path",{d:"M3 21l6-6"})]})),Ke.inheritedText]})),n.jsxs(i.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Ke.rulesCount," rules"]})),n.jsxs(i.Box,e.__assign({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Ke.tiersCount," Tiers"]}))]}))]}))]})):We.genre?null:n.jsx(i.Box,e.__assign({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:n.jsx(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))}))})),We.genre&&n.jsxs(n.Fragment,{children:[n.jsxs(i.Typography,e.__assign({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",We.genre,"” Scope"," ",n.jsx(i.Typography,e.__assign({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),n.jsxs(i.Typography,e.__assign({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",We.genre,"” category to copy its learnings."]})),n.jsxs("div",e.__assign({className:p.default.searchWrapper,style:{marginBottom:"12px"}},{children:[n.jsx("input",{type:"text",value:J,onChange:function(e){return Q(e.target.value)},placeholder:"Search for station...",className:p.default.searchInput}),n.jsx(o.Search,{className:p.default.searchIcon,size:16})]})),n.jsxs(i.Box,e.__assign({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[ie&&n.jsx(u.default,{}),!ie&&0===X.length&&ee.trim()&&n.jsxs(i.Typography,e.__assign({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',ee,'".']})),!ie&&X.map(function(r){return n.jsx(d.default,e.__assign({},r,{isSelected:ue===r.id,onSelect:function(e){var n;ce(ue===e?null!==(n=null==Ke?void 0:Ke.id)&&void 0!==n?n:null:e)}}),r.id)})]}))]})]}))]}))}))]})),n.jsxs(i.Box,e.__assign({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[n.jsx("button",e.__assign({onClick:Ze,disabled:ge,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,o,t,l,u,c,d,p,g,x,f,m,v,S,y,b,j,C,w,T,B;return e.__generator(this,function(F){switch(F.label){case 0:if(!z||!ue)return console.error("[StationOnboard] Missing required data for onboarding"),[2];if(h.useLearningTemplateStore.getState().backwardCompatibility&&"approval_required"===ke&&0===ze.length&&0===Ae.length)return Me("Please select at least one approver or approver group."),setTimeout(function(){var e;null===(e=Te.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},50),[2];Me(""),n=Ke?e.__spreadArray([Ke],X,!0):X,r=n.find(function(e){return e.id===ue}),null==r?void 0:r.isCopy,xe(!0),_e(0),i=null,F.label=1;case 1:return F.trys.push([1,3,,4]),u=h.useLearningTemplateStore.getState().backwardCompatibility,o=u?{topic:"customRuleSet",customScopeGroupName:_.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:z.station_name||"New Station",parentScopeId:null,customScopeName:z.station_name||"New Station",customScopeId:s.v4(),createByName:(null==ye?void 0:ye.firstname)||"System",createdBy:(null==ye?void 0:ye.email)||"system@audacy.com",scopeType:"Station",approvalRequired:"approval_required"===ke,appsecData:{application:null==Fe?void 0:Fe.applicationId,module:null==Fe?void 0:Fe.moduleId,roles:e.__spreadArray(e.__spreadArray([],"approval_required"===ke?[{users:ze.map(function(e){return e.email}),groups:Ae.map(function(e){return e._id}),role:null!==(v=null===(m=Be.find(function(e){return"Learning Manager"===e.name}))||void 0===m?void 0:m._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==ye?void 0:ye.email],groups:[],role:null!==(y=null===(S=Be.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===S?void 0:S._id)&&void 0!==y?y:""}],!1)}}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:z.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:k},console.log("[StationOnboard] Step 1: Creating rule set with payload:",o),[4,a.createRuleSet(o,O)];case 2:if(t=F.sent(),!(i=null===(b=null==t?void 0:t.data)||void 0===b?void 0:b.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",i),_e(1),[3,4];case 3:return l=F.sent(),console.error("[StationOnboard] Error creating rule set:",l),null===(j=be.current)||void 0===j||j.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),xe(!1),_e(0),[2];case 4:return F.trys.push([4,6,,11]),u=h.useLearningTemplateStore.getState().backwardCompatibility,c=e.__assign(e.__assign({market:z.market,region:z.region},u?{}:{timezone:We.timezone}),{primetime_windows:We.primeTime,genre:We.genre,station_type:""===We.type?null:We.type,low_sellout_configurations:"Low Sellout"===We.type?We.lowSelloutConfig:null,ruleset_id:i,station_guid:z.station_guid,station_name:z.station_name||"New Station"}),console.log("[StationOnboard] Step 2: Updating station with payload:",c),[4,a.updateStation(c)];case 5:return F.sent(),console.log("[StationOnboard] Step 2 Complete: Station updated"),_e(2),[3,11];case 6:d=F.sent(),console.error("[StationOnboard] Error updating station, rolling back rule set:",d),409===d.status?(null===(C=be.current)||void 0===C||C.show({severity:"error",life:2500,summary:"Error updating station",detail:"Station already Onboarded."}),D(null),ce(null),Se(""),Ge(function(n){return e.__assign(e.__assign({},n),{region:""})})):null===(w=be.current)||void 0===w||w.show({severity:"error",life:2500,summary:"Error updating station",detail:"Please try again."}),F.label=7;case 7:return F.trys.push([7,9,,10]),[4,a.deleteRuleSet(i,O)];case 8:return F.sent(),console.log("[StationOnboard] Rollback complete: Deleted rule set",i),[3,10];case 9:return p=F.sent(),console.error("[StationOnboard] Failed to rollback rule set deletion:",p),[3,10];case 10:return xe(!1),_e(0),[2];case 11:return F.trys.push([11,13,,14]),g=null!==ue&&ue!==(null==Ke?void 0:Ke.id),x={source_scope_id:g?ue:null!==(T=null==Ke?void 0:Ke.id)&&void 0!==T?T:ue,target_scope_id:i,is_copy_parent_variant_id:g},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",x),[4,a.inheritScopeBackwardCompatible(x)];case 12:return F.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),_e(3),[3,14];case 13:return f=F.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",f),null===(B=be.current)||void 0===B||B.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),xe(!1),_e(0),[2];case 14:return je.current=i,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!Je||ge,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:Je?"#2563EB":"#BFDBFE",color:"#fff",cursor:Je&&!ge?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:ge?n.jsxs(n.Fragment,{children:[n.jsx(i.CircularProgress,{size:16,color:"inherit"}),n.jsx("span",{children:"Onboarding..."})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Onboard Station"}),n.jsx(o.ArrowRight,{size:16})]})}))]}))]}))};
2
2
  //# sourceMappingURL=StationOnboardModal.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});require("../../../node_modules/style-inject/dist/style-inject.es.js").default(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}"),exports.default={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});require("../../../node_modules/style-inject/dist/style-inject.es.js").default(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:fit-content;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}"),exports.default={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};
2
2
  //# sourceMappingURL=Sidebar.module.css.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as o,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as i,useEffect as l}from"react";import{BookOpen as c,Users as u}from"lucide-react";import{useLearningTemplateStore as d}from"./store/useLearningTemplateStore.js";import{Toast as p}from"primereact/toast";import m from"./styles/LearningTemplateManagement.module.css.js";import f from"./LearningTemplateLayout.js";import v from"./components/EmptyLearningState.js";import h from"./store/useAuthStore.js";import{fetchTiers as g,fetchScopes as y,inheritScope as S,inheritScopeBackwardCompatible as b,createRuleSet as T,renameScope as C,updateStation as w,deleteRuleSet as E,requestAccess as L}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as I,setQueryParams as A}from"./hooks/useLearningTemplateQueryParams.js";import O from"./components/ConfirmationModal.js";import j from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as R}from"./utils/treeUtils.js";import _ from"./store/useEnvStore.js";import{useConfigStore as k}from"./store/useConfigStore.js";import{TooltipProvider as D}from"./components/ToolTip.js";import N from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import B from"./RuleContent/AddScopeModal.js";import{useLocation as M}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";var x=[{id:"learnings",label:"Learnings",icon:c,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:u}],Q=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],H=new Set(x.map(function(e){return e.id}));function K(c){var u,K=this,V=c.userDetails,W=c.llmStudioUrl,Y=c.audacyBackendUrl,z=c.ilLabels,J=c.config,X=c.rbacConfig,Z=c.app_integration_id,$=c.backwardCompatibility,ee=void 0!==$&&$,te=d(function(e){return e.selectedRuleSetId}),ne=d(function(e){return e.setSelectedRuleSetId}),re=d(function(e){return e.error}),oe=d(function(e){return e.setError}),se=d(function(e){return e.setStations}),ae=d(function(e){return e.scopeTreeData}),ie=d(function(e){return e.setScopeTreeData}),le=a({isOpen:!1,type:"GLOBAL"}),ce=le[0],ue=le[1],de=a(!1),pe=de[0],me=de[1],fe=a(!1),ve=fe[0],he=fe[1],ge=a("learnings"),ye=ge[0],Se=ge[1],be=a(null),Te=be[0],Ce=be[1],we=a(null),Ee=we[0],Le=we[1],Ie=i(null),Ae=i(null),Oe=i(null),je=h();je.user;var Re=je.setUser,_e=k(),ke=_e.setConfig,De=_e.setIlLabels,Ne=function(){try{return M()}catch(e){return{search:""}}}();l(function(){var e=new URLSearchParams(window.location.search),t=e.get(I.RULESET_ID),n=e.get(I.SECTION),r=n&&H.has(n)?n:"learnings";(null==t?void 0:t.length)&&ne&&Se&&(ne(t),Se(r))},[null==Ne?void 0:Ne.search,Se,ne]);var Pe=P(function(e){return e.fetchPermissions}),Ue=P(function(e){return e.hasPermission}),Ge=U(function(e){return e.setRoles}),Be=_(function(e){return e.appsecRbacUrl})===X.appsecRbacUrl,Me=G(X.applicationId,Be).data;l(function(){Me&&Ge(Me.map(function(e){return{_id:e._id,name:e.name}}))},[Me,Ge]),l(function(){var e;console.log("userDetails",V),Re(V),console.log("llmStudioUrl",W),console.log("audacyBackendUrl",Y),_.getState().setLlmStudioUrl(W),_.getState().setAudacyBackendUrl(Y),_.getState().setRbacConfig(X),ke(J),De(z),d.getState().setAppIntegrationId(null!=Z?Z:null),d.getState().setBackwardCompatibility(ee),d.getState().setToken(null!==(e=V.accessToken)&&void 0!==e?e:null)},[V,Re,W,Y,X,J,ke,z,De,Z,ee]),l(function(){(null==V?void 0:V.accessToken)&&W&&g()},[Z,null==V?void 0:V.accessToken,W]);var Fe=function(r){return void 0===r&&(r=!0),t(K,void 0,void 0,function(){var t,o,s,a,i,l;return n(this,function(n){switch(n.label){case 0:r&&me(!0),oe(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),[4,Pe(X.applicationId)];case 2:return n.sent(),t=function(n){if(!P.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,y(Z,V.accessToken)];case 3:return(o=n.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(a=t(s))?(Ce(null),ie({data:a}),Ae.current?(ne(Ae.current),Se("learnings"),Ae.current=null):d.getState().selectedRuleSetId||ne(a.id)):(Ce(null!==(l=s.id)&&void 0!==l?l:null),ie(null)):(Ce(null),ie(null))),[3,6];case 4:return i=n.sent(),console.error("Failed to fetch rule sets or permissions",i),oe("Failed to load data. Please try again later."),[3,6];case 5:return me(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==V?void 0:V.accessToken)||void 0===e?void 0:e.length)&&Be?Fe(!0):console.warn("Error: Trying to fetch rules without access token",V)},[null==V?void 0:V.accessToken,oe,se,X.applicationId,Be]);var qe=function(r,o,s){return t(K,void 0,void 0,function(){var t,a,i,l,c,u,p,m,f;return n(this,function(n){switch(n.label){case 0:he(!0),n.label=1;case 1:return n.trys.push([1,8,9,10]),[4,E(r,V.accessToken)];case 2:if(n.sent(),d.getState().selectedRuleSetId===r&&(t=d.getState().scopeTreeData,(a=R((null==t?void 0:t.data)||null,r))&&a.length>1&&(i=a[a.length-2],ne(i),Se("learnings"))),!s||!o)return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,w({station_name:o,ruleset_id:""})];case 4:return n.sent(),[3,6];case 5:return l=n.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,Fe(!0)];case 7:return n.sent(),ue(function(t){return e(e({},t),{isOpen:!1})}),null===(u=Oe.current)||void 0===u||u.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return c=n.sent(),console.error("An error occurred during scope deletion.",c),null===(p=Oe.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(f=null===(m=null==c?void 0:c.response)||void 0===m?void 0:m.data)||void 0===f?void 0:f.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return he(!1),[7];case 10:return[2]}})})},xe=ae,Qe=Ee?{data:{id:Ee.stationId,name:Ee.stationName,type:"STATION",metrics:{learningsCount:Ee.learningsCount,stationsCount:0},children:[]}}:xe,He=!!(null==Qe?void 0:Qe.data);null===(u=null==Qe?void 0:Qe.data)||void 0===u||u.type;var Ke=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",X.applicationResourceId||""),Ve=(Ee?x.filter(function(e){return"stations"!==e.id}):x).filter(function(e){return!(!ee&&"access"===e.id)});return r(D,{children:o("div",e({className:m.learningManagementContainer},{children:[r("div",e({className:m.mainWrapper},{children:pe?r(j,{}):re?o("div",e({className:m.errorContainer},{children:[r("div",e({className:m.errorTitle},{children:"Error Loading Data"})),r("p",e({className:m.errorDesc},{children:re})),r("button",e({onClick:function(){return Fe(!0)},className:m.tryAgainBtn},{children:"Try Again"}))]})):He?r(f,{onOpenCreateModal:function(){return ue({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return ue({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return ue({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,r,o){return t(K,void 0,void 0,function(){var t,s,a;return n(this,function(n){switch(n.label){case 0:return t=d.getState().scopeTreeData,s=R((null==t?void 0:t.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,qe(e,r,a)];case 1:return n.sent(),[3,3];case 2:ue({isOpen:!0,type:"DELETE",scopeId:e,initialName:r,isSubscope:a}),n.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ue("ilotj.scope.delete",e)},canEditScope:function(e){return Ue("ilotj.scope.edit",e)},canCreateScope:function(e){return Ue("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),A(((n={})[I.SECTION]="learnings"===t?null:t,n)),Se(t),ne(e)},activeSectionId:ye,scopeTreeData:Qe,sectionsConfig:Ve,onViewStation:function(e){Ie.current=te,Le(e),Se("learnings"),ne(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ae.current=t),Fe(e)},nodeTypesConfig:Q,app_integration_id:Z,token:V.accessToken}):r(v,{onCreate:function(){return ue({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:Ke,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(K,void 0,void 0,function(){var e,t,o,s,a,i,l,c,u;return n(this,function(n){switch(n.label){case 0:if(!(e=(null===(s=null===(o=d.getState().scopeTreeData)||void 0===o?void 0:o.data)||void 0===s?void 0:s.id)||Te))return null===(a=Oe.current)||void 0===a||a.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:"Unable to identify the global scope for this access request."})}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,L(e)];case 2:return n.sent(),null===(i=Oe.current)||void 0===i||i.show({severity:"success",sticky:!1,life:3e3,className:m.successToast,content:r(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=n.sent(),null===(l=Oe.current)||void 0===l||l.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),r(p,{ref:Oe}),ee&&ce.isOpen&&"DELETE"!==ce.type&&"RENAME"!==ce.type?r(N,{isOpen:!0,onClose:function(){return ue(e(e({},ce),{isOpen:!1}))},onSubmit:function(r){return t(K,void 0,void 0,function(){var t,o,s,a,i,l,c,u,p,m,f,v,h,g,y,C,w,E,L,I;return n(this,function(n){switch(n.label){case 0:he(!0),t=d.getState().backwardCompatibility,n.label=1;case 1:return n.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof r?o=r:(s=r,a="SCOPE"===ce.type&&ce.parentId,i=a?"genreRuleSet":ce.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ce.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:Z}),[4,T(o,V.accessToken)];case 2:if(l=n.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.scopeId))return[3,10];if(Ae.current=c,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),p=!t&&"GLOBAL"!==ce.type&&ce.parentId,!u&&!p)return[3,10];if(!(m=t?null===(w=null===(C=d.getState().scopeTreeData)||void 0===C?void 0:C.data)||void 0===w?void 0:w.id:ce.parentId))return[3,10];if(!ee)return[3,7];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,b({source_scope_id:m,target_scope_id:c})];case 4:return n.sent(),[3,6];case 5:return f=n.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return n.trys.push([7,9,,10]),[4,S({source_scope_id:m,target_scope_id:c,application_mapping_id:Z||"",is_copy_parent_variant_id:!1})];case 8:return n.sent(),[3,10];case 9:return v=n.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,Fe(!0)];case 11:return n.sent(),ue(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw h=n.sent(),console.error("An error occurred during scope creation.",h),null===(E=Oe.current)||void 0===E||E.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(L=null==h?void 0:h.response)||void 0===L?void 0:L.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),h;case 13:return he(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:He,canCreateGlobal:Ke}):r(B,{isOpen:ce.isOpen&&"DELETE"!==ce.type,onClose:function(){return ue(e(e({},ce),{isOpen:!1}))},onCreate:function(r){return o=null!=r?r:"",t(K,void 0,void 0,function(){var t,r,s,a;return n(this,function(n){switch(n.label){case 0:he(!0),n.label=1;case 1:return n.trys.push([1,4,5,6]),ce.scopeId?[4,C({scope_id:ce.scopeId,scope_name:o})]:[2];case 2:return n.sent(),[4,Fe(!0)];case 3:return n.sent(),ue(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw t=n.sent(),console.error("An error occurred during scope rename.",t),null===(r=Oe.current)||void 0===r||r.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),t;case 5:return he(!1),[7];case 6:return[2]}})});var o},hasGlobalRuleSet:He}),r(O,{isOpen:ce.isOpen&&"DELETE"===ce.type,onCancel:function(){return ue(e(e({},ce),{isOpen:!1}))},onConfirm:function(){return qe(ce.scopeId,ce.initialName,ce.isSubscope)},title:"Delete Scope",description:o(s,{children:["Deleting ",r("span",e({className:m.highlight},{children:ce.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ve})]}))})}export{K as default};
1
+ import{__assign as e,__awaiter as t,__generator as n}from"tslib";import{jsx as r,jsxs as o,Fragment as s}from"react/jsx-runtime";import{useState as a,useRef as i,useEffect as l}from"react";import{BookOpen as c,Users as u}from"lucide-react";import{useLearningTemplateStore as d}from"./store/useLearningTemplateStore.js";import{Toast as p}from"primereact/toast";import m from"./styles/LearningTemplateManagement.module.css.js";import f from"./LearningTemplateLayout.js";import v from"./components/EmptyLearningState.js";import h from"./store/useAuthStore.js";import{fetchTiers as g,fetchScopes as y,inheritScope as S,inheritScopeBackwardCompatible as b,createRuleSet as C,renameScope as T,updateStation as E,deleteRuleSet as O,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as A,setQueryParams as L}from"./hooks/useLearningTemplateQueryParams.js";import I from"./components/ConfirmationModal.js";import R from"./components/LearningTemplateManagementSkeleton.js";import{findNodePathById as j}from"./utils/treeUtils.js";import N from"./store/useEnvStore.js";import{useConfigStore as _}from"./store/useConfigStore.js";import{TooltipProvider as k}from"./components/ToolTip.js";import D from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as P}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as U}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import M from"./RuleContent/AddScopeModal.js";import{useLocation as B}from"react-router-dom";import F from"./shared/SuccessToastContent.js";import q from"./shared/ErrorToastContent.js";import x from"./RuleContent/RenameScopeModal.js";var Q=[{id:"learnings",label:"Learnings",icon:c,badgeKey:"learningsCount"},{id:"access",label:"Access",icon:u}],H=[{type:"GLOBAL",label:"Global",addChildLabel:"Add Scope",addChildType:"SCOPE"},{type:"SCOPE",label:"Scope",addChildLabel:"Add Subscope",addChildType:"SUBSCOPE"},{type:"SUBSCOPE",label:"Subscope"}],K=new Set(Q.map(function(e){return e.id}));function V(c){var u,V=this,W=c.userDetails,Y=c.llmStudioUrl,z=c.audacyBackendUrl,J=c.ilLabels,X=c.config,Z=c.rbacConfig,$=c.app_integration_id,ee=c.backwardCompatibility,te=void 0!==ee&&ee,ne=d(function(e){return e.selectedRuleSetId}),re=d(function(e){return e.setSelectedRuleSetId}),oe=d(function(e){return e.error}),se=d(function(e){return e.setError}),ae=d(function(e){return e.setStations}),ie=d(function(e){return e.scopeTreeData}),le=d(function(e){return e.setScopeTreeData}),ce=a({isOpen:!1,type:"GLOBAL"}),ue=ce[0],de=ce[1],pe=a(!1),me=pe[0],fe=pe[1],ve=a(!1),he=ve[0],ge=ve[1],ye=a("learnings"),Se=ye[0],be=ye[1],Ce=a(null),Te=Ce[0],Ee=Ce[1],Oe=a(null),we=Oe[0],Ae=Oe[1],Le=i(null),Ie=i(null),Re=i(null),je=h();je.user;var Ne=je.setUser,_e=_(),ke=_e.setConfig,De=_e.setIlLabels,Pe=function(){try{return B()}catch(e){return{search:""}}}();l(function(){var e=new URLSearchParams(window.location.search),t=e.get(A.RULESET_ID),n=e.get(A.SECTION),r=n&&K.has(n)?n:"learnings";(null==t?void 0:t.length)&&re&&be&&(re(t),be(r))},[null==Pe?void 0:Pe.search,be,re]);var Ue=P(function(e){return e.fetchPermissions}),Ge=P(function(e){return e.hasPermission}),Me=U(function(e){return e.setRoles}),Be=N(function(e){return e.appsecRbacUrl})===Z.appsecRbacUrl,Fe=G(Z.applicationId,Be).data;l(function(){Fe&&Me(Fe.map(function(e){return{_id:e._id,name:e.name}}))},[Fe,Me]),l(function(){var e;console.log("userDetails",W),Ne(W),console.log("llmStudioUrl",Y),console.log("audacyBackendUrl",z),N.getState().setLlmStudioUrl(Y),N.getState().setAudacyBackendUrl(z),N.getState().setRbacConfig(Z),ke(X),De(J),d.getState().setAppIntegrationId(null!=$?$:null),d.getState().setBackwardCompatibility(te),d.getState().setToken(null!==(e=W.accessToken)&&void 0!==e?e:null)},[W,Ne,Y,z,Z,X,ke,J,De,$,te]),l(function(){(null==W?void 0:W.accessToken)&&Y&&g()},[$,null==W?void 0:W.accessToken,Y]);var qe=function(r){return void 0===r&&(r=!0),t(V,void 0,void 0,function(){var t,o,s,a,i,l;return n(this,function(n){switch(n.label){case 0:r&&fe(!0),se(null),n.label=1;case 1:return n.trys.push([1,4,5,6]),[4,Ue(Z.applicationId)];case 2:return n.sent(),t=function(n){if(!P.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,y($,W.accessToken)];case 3:return(o=n.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(a=t(s))?(Ee(null),le({data:a}),Ie.current?(re(Ie.current),be("learnings"),Ie.current=null):d.getState().selectedRuleSetId||re(a.id)):(Ee(null!==(l=s.id)&&void 0!==l?l:null),le(null)):(Ee(null),le(null))),[3,6];case 4:return i=n.sent(),console.error("Failed to fetch rule sets or permissions",i),se("Failed to load data. Please try again later."),[3,6];case 5:return fe(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==W?void 0:W.accessToken)||void 0===e?void 0:e.length)&&Be?qe(!0):console.warn("Error: Trying to fetch rules without access token",W)},[null==W?void 0:W.accessToken,se,ae,Z.applicationId,Be]);var xe=function(r){return t(V,void 0,void 0,function(){var t,o,s,a;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,4,5,6]),ue.scopeId?[4,T({scope_id:ue.scopeId,scope_name:r})]:[2];case 2:return n.sent(),[4,qe(!0)];case 3:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw t=n.sent(),console.error("An error occurred during scope rename.",t),null===(o=Re.current)||void 0===o||o.show({severity:"error",summary:"Rename Failed",detail:(null===(a=null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.data)||void 0===a?void 0:a.message)||"There was an error renaming the scope. Please try again."}),t;case 5:return ge(!1),[7];case 6:return[2]}})})},Qe=function(r,o,s){return t(V,void 0,void 0,function(){var t,a,i,l,c,u,p,m,f;return n(this,function(n){switch(n.label){case 0:ge(!0),n.label=1;case 1:return n.trys.push([1,8,9,10]),[4,O(r,W.accessToken)];case 2:if(n.sent(),d.getState().selectedRuleSetId===r&&(t=d.getState().scopeTreeData,(a=j((null==t?void 0:t.data)||null,r))&&a.length>1&&(i=a[a.length-2],re(i),be("learnings"))),!s||!o)return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,E({station_name:o,ruleset_id:""})];case 4:return n.sent(),[3,6];case 5:return l=n.sent(),console.error("Error unlinking station on subscope delete:",l),[3,6];case 6:return[4,qe(!0)];case 7:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),null===(u=Re.current)||void 0===u||u.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,10];case 8:return c=n.sent(),console.error("An error occurred during scope deletion.",c),null===(p=Re.current)||void 0===p||p.show({severity:"error",summary:"Delete Failed",detail:(null===(f=null===(m=null==c?void 0:c.response)||void 0===m?void 0:m.data)||void 0===f?void 0:f.message)||"There was an error deleting the scope. Please try again."}),[3,10];case 9:return ge(!1),[7];case 10:return[2]}})})},He=ie,Ke=we?{data:{id:we.stationId,name:we.stationName,type:"STATION",metrics:{learningsCount:we.learningsCount,stationsCount:0},children:[]}}:He,Ve=!!(null==Ke?void 0:Ke.data);null===(u=null==Ke?void 0:Ke.data)||void 0===u||u.type;var We=P(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",Z.applicationResourceId||""),Ye=(we?Q.filter(function(e){return"stations"!==e.id}):Q).filter(function(e){return!(!te&&"access"===e.id)});return r(k,{children:o("div",e({className:m.learningManagementContainer},{children:[r("div",e({className:m.mainWrapper},{children:me?r(R,{}):oe?o("div",e({className:m.errorContainer},{children:[r("div",e({className:m.errorTitle},{children:"Error Loading Data"})),r("p",e({className:m.errorDesc},{children:oe})),r("button",e({onClick:function(){return qe(!0)},className:m.tryAgainBtn},{children:"Try Again"}))]})):Ve?r(f,{onOpenCreateModal:function(){return de({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return de({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return de({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,r,o){return t(V,void 0,void 0,function(){var t,s,a;return n(this,function(n){switch(n.label){case 0:return t=d.getState().scopeTreeData,s=j((null==t?void 0:t.data)||null,e),a=!!s&&3===s.length,0!==o?[3,2]:[4,Qe(e,r,a)];case 1:return n.sent(),[3,3];case 2:de({isOpen:!0,type:"DELETE",scopeId:e,initialName:r,isSubscope:a}),n.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Ge("ilotj.scope.delete",e)},canEditScope:function(e){return Ge("ilotj.scope.edit",e)},canCreateScope:function(e){return Ge("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),L(((n={})[A.SECTION]="learnings"===t?null:t,n)),be(t),re(e)},activeSectionId:Se,scopeTreeData:Ke,sectionsConfig:Ye,onViewStation:function(e){Le.current=ne,Ae(e),be("learnings"),re(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ie.current=t),qe(e)},nodeTypesConfig:H,app_integration_id:$,token:W.accessToken}):r(v,{onCreate:function(){return de({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:We,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return t(V,void 0,void 0,function(){var e,t,o,s,a,i,l,c,u;return n(this,function(n){switch(n.label){case 0:if(!(e=(null===(s=null===(o=d.getState().scopeTreeData)||void 0===o?void 0:o.data)||void 0===s?void 0:s.id)||Te))return null===(a=Re.current)||void 0===a||a.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:"Unable to identify the global scope for this access request."})}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,w(e)];case 2:return n.sent(),null===(i=Re.current)||void 0===i||i.show({severity:"success",sticky:!1,life:3e3,className:m.successToast,content:r(F,{message:"Access request submitted successfully!"})}),[3,4];case 3:return t=n.sent(),null===(l=Re.current)||void 0===l||l.show({severity:"error",sticky:!1,className:m.errorToast,content:r(q,{message:(null===(u=null===(c=null==t?void 0:t.response)||void 0===c?void 0:c.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),r(p,{ref:Re}),te&&ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type?r(D,{isOpen:!0,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSubmit:function(r){return t(V,void 0,void 0,function(){var t,o,s,a,i,l,c,u,p,m,f,v,h,g,y,T,E,O,w,A;return n(this,function(n){switch(n.label){case 0:ge(!0),t=d.getState().backwardCompatibility,n.label=1;case 1:return n.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof r?o=r:(s=r,a="SCOPE"===ue.type&&ue.parentId,i=a?"genreRuleSet":ue.type,o={topic:i,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ue.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:$}),[4,C(o,W.accessToken)];case 2:if(l=n.sent(),!(c=null===(g=null==l?void 0:l.data)||void 0===g?void 0:g.scopeId))return[3,10];if(Ie.current=c,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),p=!t&&"GLOBAL"!==ue.type&&ue.parentId,!u&&!p)return[3,10];if(!(m=t?null===(E=null===(T=d.getState().scopeTreeData)||void 0===T?void 0:T.data)||void 0===E?void 0:E.id:ue.parentId))return[3,10];if(!te)return[3,7];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,b({source_scope_id:m,target_scope_id:c})];case 4:return n.sent(),[3,6];case 5:return f=n.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return n.trys.push([7,9,,10]),[4,S({source_scope_id:m,target_scope_id:c,application_mapping_id:$||"",is_copy_parent_variant_id:!1})];case 8:return n.sent(),[3,10];case 9:return v=n.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,qe(!0)];case 11:return n.sent(),de(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw h=n.sent(),console.error("An error occurred during scope creation.",h),null===(O=Re.current)||void 0===O||O.show({severity:"error",summary:"Creation Failed",detail:(null===(A=null===(w=null==h?void 0:h.response)||void 0===w?void 0:w.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),h;case 13:return ge(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ve,canCreateGlobal:We}):o(s,{children:[r(M,{isOpen:ue.isOpen&&"DELETE"!==ue.type&&"RENAME"!==ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onCreate:function(e){return xe(null!=e?e:"")},hasGlobalRuleSet:Ve}),r(x,{isOpen:ue.isOpen&&"RENAME"===ue.type,onClose:function(){return de(e(e({},ue),{isOpen:!1}))},onSave:xe,initialName:ue.initialName})]}),r(I,{isOpen:ue.isOpen&&"DELETE"===ue.type,onCancel:function(){return de(e(e({},ue),{isOpen:!1}))},onConfirm:function(){return Qe(ue.scopeId,ue.initialName,ue.isSubscope)},title:"Delete Scope",description:o(s,{children:["Deleting ",r("span",e({className:m.highlight},{children:ue.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:he})]}))})}export{V as default};
2
2
  //# sourceMappingURL=LearningManagement.js.map
@@ -0,0 +1,2 @@
1
+ import{__assign as e,__awaiter as n,__generator as o}from"tslib";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{useState as i,useRef as l,useEffect as a}from"react";import{X as d}from"lucide-react";var c=function(c){var s=c.isOpen,p=c.onClose,u=c.onSave,f=c.initialName,x=void 0===f?"":f,g=i(x),b=g[0],y=g[1],m=i(""),h=m[0],v=m[1],C=i(!1),S=C[0],E=C[1],k=l(null);if(a(function(){s&&(y(x),v(""),setTimeout(function(){var e,n;null===(e=k.current)||void 0===e||e.focus(),null===(n=k.current)||void 0===n||n.select()},50))},[s,x]),!s)return null;var z=function(){return n(void 0,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:if(!b.trim())return v("Scope Name is required"),[2];v(""),E(!0),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,u(b.trim())];case 2:return e.sent(),p(),[3,5];case 3:return e.sent(),v("Failed to rename scope. Please try again."),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})};return t("div",e({style:{position:"fixed",inset:0,zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"},onClick:function(e){e.target===e.currentTarget&&p()}},{children:r("div",e({style:{width:"480px",backgroundColor:"#fff",borderRadius:"12px",boxShadow:"0 20px 60px rgba(0,0,0,0.15)",padding:"24px",fontFamily:"sans-serif"}},{children:[r("div",e({style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"}},{children:[t("span",e({style:{fontSize:"16px",fontWeight:600,color:"#19213D"}},{children:"Rename Scope"})),t("button",e({onClick:p,disabled:S,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",padding:"4px",lineHeight:0}},{children:t(d,{size:20})}))]})),r("div",e({style:{display:"flex",flexDirection:"column",gap:"6px",marginBottom:"24px"}},{children:[r("label",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:[t("span",e({style:{color:"#E53E3E",marginRight:"3px"}},{children:"*"})),"Scope Name"]})),t("input",{ref:k,type:"text",value:b,onChange:function(e){y(e.target.value),h&&v("")},onKeyDown:function(e){"Enter"===e.key&&z(),"Escape"===e.key&&p()},placeholder:"Enter scope name",style:{padding:"8px 12px",fontSize:"14px",color:"#19213D",borderRadius:"6px",border:"1px solid ".concat(h?"#EF4444":"#E2E8F0"),outline:"none",width:"100%",boxSizing:"border-box"}}),h&&t("p",e({style:{margin:0,fontSize:"12px",color:"#EF4444"}},{children:h}))]})),r("div",e({style:{display:"flex",justifyContent:"flex-end",gap:"10px"}},{children:[t("button",e({onClick:p,disabled:S,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #E2E8F0",backgroundColor:"#fff",color:"#64748B",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.6:1}},{children:"Cancel"})),t("button",e({onClick:z,disabled:S,style:{padding:"8px 20px",borderRadius:"6px",border:"none",backgroundColor:"#2563EB",color:"#fff",fontSize:"14px",fontWeight:500,cursor:S?"not-allowed":"pointer",opacity:S?.7:1}},{children:S?"Saving...":"Save"}))]}))]}))}))};export{c as default};
2
+ //# sourceMappingURL=RenameScopeModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenameScopeModal.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- import{__assign as e,__awaiter as o,__generator as n,__spreadArray as r}from"tslib";import{jsxs as t,jsx as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useMemo as c,useEffect as u}from"react";import{Dialog as d,Box as p,Typography as m,IconButton as f,DialogContent as h,CircularProgress as g}from"@mui/material";import{X as x,Brush as b,Search as v,ArrowRight as S}from"lucide-react";import{Toast as y}from"primereact/toast";import{v4 as C}from"uuid";import{retrieveGenreScopes as w,searchScopes as T,inheritScopeBackwardCompatible as F,deleteRuleSet as _,updateStation as O,createRuleSet as E}from"../../apis/scopeApis.js";import k from"./StationAutocomplete.js";import z from"../CardSkeleton.js";import B from"./OnboardingLoader.js";import D from"./TemplateCard.js";import N from"../../styles/StationOnboardModal.module.css.js";import I from"./InputField.js";import j from"../../store/useAuthStore.js";import{useConfigStore as M}from"../../store/useConfigStore.js";import{useLearningTemplateStore as R}from"../../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as A}from"../../config.js";var L=[{label:"PT - Pacific Time",value:"Pacific Time"},{label:"MT - Mountain Time",value:"Mountain Time"},{label:"CT - Central Time",value:"Central Time"},{label:"ET - Eastern Time",value:"Eastern Time"}],W=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],P=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],q=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}],U=function(U){var Y,G=U.isOpen,H=U.onClose,Z=U.onBoardStation,K=U.app_integration_id,X=U.token,J=a(null),Q=J[0],V=J[1],$=a([]),ee=$[0],oe=$[1],ne=a(0),re=ne[0],te=ne[1],ie=a(!0),le=ie[0],ae=ie[1],se=a(!1),ce=se[0],ue=se[1],de=a([]),pe=de[0],me=de[1],fe=a(""),he=fe[0],ge=fe[1],xe=a(""),be=xe[0],ve=xe[1],Se=a(!1),ye=Se[0],Ce=Se[1],we=a(!1),Te=we[0],Fe=we[1],_e=a(null),Oe=_e[0],Ee=_e[1],ke=a(null);ke[0],ke[1];var ze=a(!1),Be=ze[0],De=ze[1],Ne=a(0),Ie=Ne[0],je=Ne[1],Me=a(""),Re=Me[0],Ae=Me[1],Le=j().user,We=s(null),Pe=s(null),qe=s(null),Ue=s(null);M().configuration;var Ye=a({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),Ge=Ye[0],He=Ye[1],Ze=function(e,o){return e.find(function(e){return e.value===o})||null},Ke=c(function(){return ee.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[ee]),Xe=c(function(){var e,o,n;if(!Ge.genre)return null;var r=ee.find(function(e){return e.scope_name===Ge.genre});return r?{id:r.id,title:r.scope_name||"Unnamed Template",description:(null===(e=r.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(o=r.inheritance)||void 0===o?void 0:o[0])||void 0,rulesCount:r.rules_count||0,tiersCount:r.tier_count||0,isCopy:null!==(n=r.is_copy)&&void 0!==n&&n}:null},[Ge.genre,ee]);u(function(){return function(){qe.current&&clearTimeout(qe.current)}},[]);var Je=function(e){return o(void 0,void 0,void 0,function(){var o,t,i;return n(this,function(n){switch(n.label){case 0:if(ce)return[2];ue(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,w({limit:"20",offset:String(e)})];case 2:return"success"===(null==(o=n.sent())?void 0:o.status)&&Array.isArray(null==o?void 0:o.data)?(t=o.data,oe(function(o){if(0===e)return t;var n=new Set(o.map(function(e){return e.id})),i=t.filter(function(e){return!n.has(e.id)});return r(r([],o,!0),i,!0)}),t.length<20?ae(!1):ae(!0),te(e+20)):ae(!1),[3,5];case 3:return i=n.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",i),ae(!1),[3,5];case 4:return ue(!1),[7];case 5:return[2]}})})};u(function(){G&&(oe([]),te(0),ae(!0),Je(0))},[G]);u(function(){He(Q?function(o){var n;return e(e({},o),{region:null!==(n=Q.market)&&void 0!==n?n:""})}:{region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""})},[Q]),u(function(){var e=setTimeout(function(){ve(he)},500);return function(){return clearTimeout(e)}},[he]),u(function(){o(void 0,void 0,void 0,function(){var e,o,r,t;return n(this,function(n){switch(n.label){case 0:if(!be.trim())return me([]),[2];Ce(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,T({search_string:be})];case 2:return"success"===(null==(e=n.sent())?void 0:e.status)&&Array.isArray(null==e?void 0:e.data)?(o=e.data.filter(function(e){var o,n=null!==(o=e.inheritance)&&void 0!==o?o:[],r=n.indexOf(e.scope_name);return!(r<=0)&&n[r-1]===Ge.genre}),r=o.map(function(e){var o,n,r;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(o=e.description)||void 0===o?void 0:o.trim())||"No description available.",inheritedText:(null===(n=e.inheritance)||void 0===n?void 0:n[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(r=e.is_copy)&&void 0!==r&&r}}),me(r)):me([]),[3,5];case 3:return t=n.sent(),console.error("[StationOnboard] Error searching scopes:",t),me([]),[3,5];case 4:return Ce(!1),[7];case 5:return[2]}})})},[be,Ge.genre]),u(function(){!be.trim()&&Xe&&Ee(Xe.id)},[be,Xe]);var Qe=function(){setTimeout(function(){Ue.current&&Ue.current.scrollTo({top:Ue.current.scrollHeight,behavior:"smooth"})},100)},Ve=function(){Ae(""),V(null),He({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),me([]),ge(""),Ee(null),H()},$e=function(o,n){var r;if("primeTime"!==o){var t=null!==(r=null==n?void 0:n.value)&&void 0!==r?r:"";He(function(n){var r;return e(e({},n),((r={})[o]=String(t),r))}),"genre"===o&&(Fe(!0),qe.current&&clearTimeout(qe.current),qe.current=setTimeout(function(){var e=ee.find(function(e){return e.scope_name===t});Ee(e?e.id:null),Fe(!1)},800))}else{var i=(null==n?void 0:n.value)?String(n.value):"";He(function(o){return e(e({},o),{primeTime:i?[i]:[]})})}},eo=Boolean(Q&&Ge.region&&Ge.timezone&&Ge.primeTime.length>0&&Ge.genre);return t(d,e({open:G,onClose:Ve,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[i(y,{ref:We}),t(p,e({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[t(p,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[i(m,e({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),i(m,e({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),i(f,e({onClick:Ve,disabled:Be,sx:{color:"#19213D"}},{children:i(x,{size:24})}))]})),t(h,e({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[i(B,{isLoading:Be,currentStep:Ie,onComplete:function(){De(!1);var e=Pe.current;Ve(),Z(e||void 0),Pe.current=null}}),t(p,e({sx:{display:"flex",flex:1,paddingY:"14px",paddingX:"20px",gap:3,overflowY:"hidden"}},{children:[t(p,e({ref:Ue,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5",height:"100%",overflowY:"auto"}},{children:[i(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),i(m,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),t(p,e({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[t(p,e({className:N.formGroup},{children:[t("label",e({className:N.label},{children:[i("span",e({className:N.asterisk},{children:"*"})),"Station Name/Call Letters"]})),i(k,{value:Re,onChange:Ae,onStationSelect:function(e){return V(e)}})]})),i(I,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:Ge.region||void 0,isSearchable:!1}),i(I,{required:!0,label:"TimeZone",placeholder:"Select TimeZone",options:L,value:Ze(L,Ge.timezone),onOptionChange:function(e){return $e("timezone",e)},isSearchable:!1}),i(I,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:W,value:Ze(W,(null===(Y=Ge.primeTime)||void 0===Y?void 0:Y[0])||""),onOptionChange:function(e){return $e("primeTime",e)},isSearchable:!1}),i(p,e({onClick:Qe,sx:{width:"100%"}},{children:i(I,{label:"Station Type",placeholder:"None",options:P,value:Ze(P,Ge.type),onOptionChange:function(o){$e("type",o),"Low Sellout"!==(null==o?void 0:o.value)&&He(function(o){return e(e({},o),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===Ge.type&&i(p,e({onClick:Qe,sx:{width:"100%"}},{children:i(I,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:q,value:Ze(q,Ge.lowSelloutConfig),onOptionChange:function(e){return $e("lowSelloutConfig",e)},isSearchable:!1})}))]}))]})),t(p,e({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column",height:"100%",overflowY:"auto"}},{children:[t(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[i("span",e({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),i(m,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),i(p,e({sx:{mb:2}},{children:i(I,{required:!0,label:"",placeholder:"Select Genre",options:Ke,value:Ze(Ke,Ge.genre),onOptionChange:function(e){return $e("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!ce&&le&&Je(re)},isLoadingOptions:ce,hasMoreOptions:le})})),i(p,e({sx:{mb:3}},{children:Te?i(z,{}):Xe?t(p,e({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[i(p,e({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:t("svg",e({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[i("circle",{cx:"12",cy:"12",r:"2"}),i("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),t(p,e({sx:{flex:1,minWidth:0}},{children:[i(m,e({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:Xe.title})),i(m,e({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:Xe.description})),t(p,e({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[Xe.inheritedText&&t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[t("svg",e({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[i("polyline",{points:"15 3 21 3 21 9"}),i("path",{d:"M21 3L9 15"}),i("path",{d:"M3 21l6-6"})]})),Xe.inheritedText]})),t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Xe.rulesCount," rules"]})),t(p,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[Xe.tiersCount," Tiers"]}))]}))]}))]})):Ge.genre?null:t(p,e({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:[i(b,{size:28}),i(m,e({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))]}))})),Ge.genre&&t(l,{children:[t(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",Ge.genre,"” Scope"," ",i(m,e({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),t(m,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",Ge.genre,"” category to copy its learnings."]})),t("div",e({className:N.searchWrapper,style:{marginBottom:"12px"}},{children:[i("input",{type:"text",value:he,onChange:function(e){return ge(e.target.value)},placeholder:"Search for station...",className:N.searchInput}),i(v,{className:N.searchIcon,size:16})]})),t(p,e({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[ye&&i(z,{}),!ye&&0===pe.length&&be.trim()&&t(m,e({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',be,'".']})),!ye&&pe.map(function(o){return i(D,e({},o,{isSelected:Oe===o.id,onSelect:function(e){var o;Ee(Oe===e?null!==(o=null==Xe?void 0:Xe.id)&&void 0!==o?o:null:e)}}),o.id)})]}))]})]}))]}))]})),t(p,e({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[i("button",e({onClick:Ve,disabled:Be,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),i("button",e({onClick:function(){return o(void 0,void 0,void 0,function(){var o,t,i,l,a,s,c,u,d,p,m,f,h,g,x,b,v,S,y;return n(this,function(n){switch(n.label){case 0:if(!Q||!Oe)return console.error("[StationOnboard] Missing required data for onboarding"),[2];o=Xe?r([Xe],pe,!0):pe,t=o.find(function(e){return e.id===Oe}),null==t?void 0:t.isCopy,De(!0),je(0),i=null,n.label=1;case 1:return n.trys.push([1,3,,4]),c=R.getState().backwardCompatibility,l=c?{topic:"customRuleSet",customScopeGroupName:A.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:Q.station_name||"New Station",parentScopeId:null,customScopeName:Q.station_name||"New Station",customScopeId:C(),createByName:(null==Le?void 0:Le.firstname)||"System",createdBy:(null==Le?void 0:Le.email)||"system@audacy.com",scopeType:"Station"}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:Q.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:K},console.log("[StationOnboard] Step 1: Creating rule set with payload:",l),[4,E(l,X)];case 2:if(a=n.sent(),!(i=null===(g=null==a?void 0:a.data)||void 0===g?void 0:g.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",i),je(1),[3,4];case 3:return s=n.sent(),console.error("[StationOnboard] Error creating rule set:",s),null===(x=We.current)||void 0===x||x.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),De(!1),je(0),[2];case 4:return n.trys.push([4,6,,11]),c=R.getState().backwardCompatibility,u=e(e({market:Q.market,region:Q.region},c?{}:{timezone:Ge.timezone}),{primetime_windows:Ge.primeTime,genre:Ge.genre,station_type:""===Ge.type?null:Ge.type,low_sellout_configurations:"Low Sellout"===Ge.type?Ge.lowSelloutConfig:null,ruleset_id:i,station_guid:Q.station_guid,station_name:Q.station_name||"New Station"}),console.log("[StationOnboard] Step 2: Updating station with payload:",u),[4,O(u)];case 5:return n.sent(),console.log("[StationOnboard] Step 2 Complete: Station updated"),je(2),[3,11];case 6:d=n.sent(),console.error("[StationOnboard] Error updating station, rolling back rule set:",d),409===d.status?(null===(b=We.current)||void 0===b||b.show({severity:"error",life:2500,summary:"Error updating station",detail:"Station already Onboarded."}),V(null),Ee(null),Ae(""),He(function(o){return e(e({},o),{region:""})})):null===(v=We.current)||void 0===v||v.show({severity:"error",life:2500,summary:"Error updating station",detail:"Please try again."}),n.label=7;case 7:return n.trys.push([7,9,,10]),[4,_(i,X)];case 8:return n.sent(),console.log("[StationOnboard] Rollback complete: Deleted rule set",i),[3,10];case 9:return p=n.sent(),console.error("[StationOnboard] Failed to rollback rule set deletion:",p),[3,10];case 10:return De(!1),je(0),[2];case 11:return n.trys.push([11,13,,14]),m=null!==Oe&&Oe!==(null==Xe?void 0:Xe.id),f={source_scope_id:m?Oe:null!==(S=null==Xe?void 0:Xe.id)&&void 0!==S?S:Oe,target_scope_id:i,is_copy_parent_variant_id:m},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",f),[4,F(f)];case 12:return n.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),je(3),[3,14];case 13:return h=n.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",h),null===(y=We.current)||void 0===y||y.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),De(!1),je(0),[2];case 14:return Pe.current=i,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!eo||Be,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:eo?"#2563EB":"#BFDBFE",color:"#fff",cursor:eo&&!Be?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:t(l,Be?{children:[i(g,{size:16,color:"inherit"}),i("span",{children:"Onboarding..."})]}:{children:[i("span",{children:"Onboard Station"}),i(S,{size:16})]})}))]}))]}))};export{U as default};
1
+ import{__assign as e,__awaiter as o,__generator as r,__spreadArray as n}from"tslib";import{jsxs as i,jsx as t,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useMemo as c,useEffect as u}from"react";import{Dialog as p,Box as d,Typography as m,IconButton as f,DialogContent as h,CircularProgress as g}from"@mui/material";import{X as x,Search as v,ArrowRight as b}from"lucide-react";import{Toast as S}from"primereact/toast";import{v4 as y}from"uuid";import{retrieveGenreScopes as C,searchScopes as w,inheritScopeBackwardCompatible as _,deleteRuleSet as F,updateStation as T,createRuleSet as k}from"../../apis/scopeApis.js";import E from"./StationAutocomplete.js";import z from"../CardSkeleton.js";import O from"./OnboardingLoader.js";import D from"./TemplateCard.js";import B from"../../styles/StationOnboardModal.module.css.js";import I from"./InputField.js";import A from"../../store/useAuthStore.js";import{useConfigStore as R}from"../../store/useConfigStore.js";import{useLearningTemplateStore as j}from"../../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as L}from"../../config.js";import{useAppSecRolesStore as N}from"../../store/useAppSecRolesStore.js";import W from"../../store/useEnvStore.js";import q from"../../RuleContent/AddScopeApprovalSearchComponent.js";var M=[{label:"PT - Pacific Time",value:"Pacific Time"},{label:"MT - Mountain Time",value:"Mountain Time"},{label:"CT - Central Time",value:"Central Time"},{label:"ET - Eastern Time",value:"Eastern Time"}],P=[{label:"6am to 7pm",value:"06:00 AM - 7:00 PM"},{label:"5am to 7pm",value:"05:00 AM - 7:00 PM"}],G=[{label:"Low Sellout",value:"Low Sellout"},{label:"High Sellout",value:"High Sellout"},{label:"None",value:""}],U=[{label:"None",value:"None"},{label:"Distribute spots evenly across all breaks in the hour",value:"Distribute spots evenly across all breaks in the hour"}],H=function(H){var K,Y=H.isOpen,Z=H.onClose,V=H.onBoardStation,X=H.app_integration_id,J=H.token,Q=a(null),$=Q[0],ee=Q[1],oe=a([]),re=oe[0],ne=oe[1],ie=a(0),te=ie[0],le=ie[1],ae=a(!0),se=ae[0],ce=ae[1],ue=a(!1),pe=ue[0],de=ue[1],me=a([]),fe=me[0],he=me[1],ge=a(""),xe=ge[0],ve=ge[1],be=a(""),Se=be[0],ye=be[1],Ce=a(!1),we=Ce[0],_e=Ce[1],Fe=a(!1),Te=Fe[0],ke=Fe[1],Ee=a(null),ze=Ee[0],Oe=Ee[1],De=a(null);De[0],De[1];var Be=a(!1),Ie=Be[0],Ae=Be[1],Re=a(0),je=Re[0],Le=Re[1],Ne=a(""),We=Ne[0],qe=Ne[1],Me=A().user,Pe=s(null),Ge=s(null),Ue=s(null),He=s(null);R().configuration;var Ke=s(null),Ye=N(function(e){return e.roles}),Ze=W(function(e){return e.rbacConfig}),Ve=a("approval_required"),Xe=Ve[0],Je=Ve[1],Qe=a([]),$e=Qe[0],eo=Qe[1],oo=a([]),ro=oo[0],no=oo[1],io=a(""),to=io[0],lo=io[1],ao=a({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),so=ao[0],co=ao[1],uo=function(e,o){return e.find(function(e){return e.value===o})||null},po=c(function(){return re.map(function(e){return{label:e.scope_name,value:e.scope_name}})},[re]),mo=c(function(){var e,o,r;if(!so.genre)return null;var n=re.find(function(e){return e.scope_name===so.genre});return n?{id:n.id,title:n.scope_name||"Unnamed Template",description:(null===(e=n.description)||void 0===e?void 0:e.trim())||"No description available.",inheritedText:(null===(o=n.inheritance)||void 0===o?void 0:o[0])||void 0,rulesCount:n.rules_count||0,tiersCount:n.tier_count||0,isCopy:null!==(r=n.is_copy)&&void 0!==r&&r}:null},[so.genre,re]);u(function(){return function(){Ue.current&&clearTimeout(Ue.current)}},[]);var fo=function(e){return o(void 0,void 0,void 0,function(){var o,i,t;return r(this,function(r){switch(r.label){case 0:if(pe)return[2];de(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,C({limit:"20",offset:String(e)})];case 2:return"success"===(null==(o=r.sent())?void 0:o.status)&&Array.isArray(null==o?void 0:o.data)?(i=o.data,ne(function(o){if(0===e)return i;var r=new Set(o.map(function(e){return e.id})),t=i.filter(function(e){return!r.has(e.id)});return n(n([],o,!0),t,!0)}),i.length<20?ce(!1):ce(!0),le(e+20)):ce(!1),[3,5];case 3:return t=r.sent(),console.error("[StationOnboard] Failed to fetch genre scopes:",t),ce(!1),[3,5];case 4:return de(!1),[7];case 5:return[2]}})})};u(function(){Y&&(ne([]),le(0),ce(!0),fo(0))},[Y]);u(function(){co($?function(o){var r;return e(e({},o),{region:null!==(r=$.market)&&void 0!==r?r:""})}:{region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""})},[$]),u(function(){var e=setTimeout(function(){ye(xe)},500);return function(){return clearTimeout(e)}},[xe]),u(function(){o(void 0,void 0,void 0,function(){var e,o,n,i;return r(this,function(r){switch(r.label){case 0:if(!Se.trim())return he([]),[2];_e(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,w({search_string:Se})];case 2:return"success"===(null==(e=r.sent())?void 0:e.status)&&Array.isArray(null==e?void 0:e.data)?(o=e.data.filter(function(e){var o,r=null!==(o=e.inheritance)&&void 0!==o?o:[],n=r.indexOf(e.scope_name);return!(n<=0)&&r[n-1]===so.genre}),n=o.map(function(e){var o,r,n;return{id:e.id,title:e.scope_name||"Unnamed Template",description:(null===(o=e.description)||void 0===o?void 0:o.trim())||"No description available.",inheritedText:(null===(r=e.inheritance)||void 0===r?void 0:r[0])||void 0,rulesCount:e.rules_count||0,tiersCount:e.tier_count||0,isCopy:null!==(n=e.is_copy)&&void 0!==n&&n}}),he(n)):he([]),[3,5];case 3:return i=r.sent(),console.error("[StationOnboard] Error searching scopes:",i),he([]),[3,5];case 4:return _e(!1),[7];case 5:return[2]}})})},[Se,so.genre]),u(function(){!Se.trim()&&mo&&Oe(mo.id)},[Se,mo]);var ho=function(){setTimeout(function(){He.current&&He.current.scrollTo({top:He.current.scrollHeight,behavior:"smooth"})},100)},go=function(){qe(""),ee(null),co({region:"",timezone:"",primeTime:[],genre:"",type:"",lowSelloutConfig:""}),he([]),ve(""),Oe(null),Je("approval_required"),eo([]),no([]),lo(""),Z()},xo=function(o,r){var n;if("primeTime"!==o){var i=null!==(n=null==r?void 0:r.value)&&void 0!==n?n:"";co(function(r){var n;return e(e({},r),((n={})[o]=String(i),n))}),"genre"===o&&(ke(!0),Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(function(){var e=re.find(function(e){return e.scope_name===i});Oe(e?e.id:null),ke(!1)},800))}else{var t=(null==r?void 0:r.value)?String(r.value):"";co(function(o){return e(e({},o),{primeTime:t?[t]:[]})})}},vo=Boolean($&&so.region&&so.timezone&&so.primeTime.length>0&&so.genre);return i(p,e({open:Y,onClose:go,maxWidth:!1,disableEscapeKeyDown:!0,PaperProps:{sx:{width:"90vw",height:"90vh",borderRadius:"12px",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"sans-serif"}}},{children:[t(S,{ref:Pe}),i(d,e({sx:{p:"20px 20px 20px 27px",borderBottom:"1px solid #F0F2F5",display:"flex",justifyContent:"space-between",alignItems:"center",bgcolor:"#fff"}},{children:[i(d,e({sx:{display:"flex",flexDirection:"column",gap:.5}},{children:[t(m,e({sx:{fontSize:"18px",fontWeight:600,color:"#19213D"}},{children:"Onboard a Station"})),t(m,e({sx:{fontSize:"16px",fontWeight:400,color:"#666F8D"}},{children:"Onboard a station to start configuring learnings."}))]})),t(f,e({onClick:go,disabled:Ie,sx:{color:"#19213D"}},{children:t(x,{size:24})}))]})),i(h,e({sx:{p:0,bgcolor:"#F8FAFC",display:"flex",flexDirection:"row",overflow:"hidden",position:"relative"}},{children:[t(O,{isLoading:Ie,currentStep:je,onComplete:function(){Ae(!1);var e=Ge.current;go(),V(e||void 0),Ge.current=null}}),t(d,e({sx:{display:"flex",flex:1,flexDirection:"column",paddingY:"14px",paddingX:"20px",gap:2,overflowY:"auto"}},{children:i(d,e({sx:{display:"flex",gap:3}},{children:[i(d,e({ref:He,sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"16px",border:"1px solid #F0F2F5"}},{children:[t(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Basic Details"})),t(m,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Set up basic station details to unlock AI recommended scopes."})),i(d,e({sx:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[i(d,e({className:B.formGroup},{children:[i("label",e({className:B.label},{children:[t("span",e({className:B.asterisk},{children:"*"})),"Station Name/Call Letters"]})),t(E,{value:We,onChange:qe,onStationSelect:function(e){return ee(e)}})]})),t(I,{required:!0,disabled:!0,label:"Region",placeholder:"Select Region",value:so.region||void 0,isSearchable:!1}),t(I,{required:!0,label:"TimeZone",placeholder:"Select TimeZone",options:M,value:uo(M,so.timezone),onOptionChange:function(e){return xo("timezone",e)},isSearchable:!1}),t(I,{required:!0,label:"Prime Time Window",placeholder:"Select Prime Time",options:P,value:uo(P,(null===(K=so.primeTime)||void 0===K?void 0:K[0])||""),onOptionChange:function(e){return xo("primeTime",e)},isSearchable:!1}),t(d,e({onClick:ho,sx:{width:"100%"}},{children:t(I,{label:"Station Type",placeholder:"None",options:G,value:uo(G,so.type),onOptionChange:function(o){xo("type",o),"Low Sellout"!==(null==o?void 0:o.value)&&co(function(o){return e(e({},o),{lowSelloutConfig:""})})},isSearchable:!1})})),"Low Sellout"===so.type&&t(d,e({onClick:ho,sx:{width:"100%"}},{children:t(I,{label:"Low Sell Out Configurations",placeholder:"Select Configuration",options:U,value:uo(U,so.lowSelloutConfig),onOptionChange:function(e){return xo("lowSelloutConfig",e)},isSearchable:!1})})),j.getState().backwardCompatibility&&i("div",e({ref:Ke,style:{display:"flex",flexDirection:"column",marginTop:"12px"}},{children:[t(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:"Approval Settings"})),t(m,e({sx:{fontSize:"0.75rem",color:"#00000080",mb:"20px"}},{children:"Configure who can approve learnings before they get published."})),i("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"16px"}},{children:[i("div",e({style:{marginBottom:"12px",fontSize:"12px",color:"#8F2C23",gap:"12px"}},{children:[i("div",e({role:"radio","aria-checked":"approval_required"===Xe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px",marginBottom:"8px"},onClick:function(){return Je("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||Je("approval_required")}},{children:[i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Xe?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Xe&&t("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Approval Required Before Publishing"}))]})),t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings require approval before publishing."}))]})),i("div",e({style:{gap:"16px"}},{children:["approval_required"===Xe&&t(q,{selectedApprovers:$e,selectedGroupOfApprovers:ro,onApproversChange:function(e){eo(e),lo("")},onGroupsChange:function(e){no(e),lo("")}}),to&&t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#8F2C23"}},{children:to}))]}))]})),i("div",e({role:"radio","aria-checked":"publish_without"===Xe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:"4px"},onClick:function(){Je("publish_without"),lo("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(Je("publish_without"),lo(""))}},{children:[i("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t("div",e({style:{display:"flex",height:"16px",width:"16px",flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Xe?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Xe&&t("div",{style:{height:"8px",width:"8px",borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",e({style:{fontSize:"14px",fontWeight:500,color:"#19213D"}},{children:"Publish Without Approval"}))]})),t("p",e({style:{margin:0,marginLeft:"24px",fontSize:"12px",color:"#666F8D"}},{children:"Learnings can be published directly."}))]}))]}))]}))]}))]})),i(d,e({sx:{flex:1,bgcolor:"#fff",p:3,borderRadius:"12px",border:"1px solid #F0F2F5",display:"flex",flexDirection:"column"}},{children:[i(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:[t("span",e({style:{color:"#E53E3E",marginRight:"2px"}},{children:"*"})),"Select a scope for your station"]})),t(m,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"16px"}},{children:"Your station will inherit the rules from the selected scope."})),t(d,e({sx:{mb:2}},{children:t(I,{required:!0,label:"",placeholder:"Select Genre",options:po,value:uo(po,so.genre),onOptionChange:function(e){return xo("genre",e)},isSearchable:!1,onMenuScrollToBottom:function(){!pe&&se&&fo(te)},isLoadingOptions:pe,hasMoreOptions:se})})),t(d,e({sx:{mb:3}},{children:Te?t(z,{}):mo?i(d,e({sx:{border:"1.5px solid #2563EB",borderRadius:"10px",p:"14px 16px",bgcolor:"#EFF6FF",display:"flex",alignItems:"flex-start",gap:"12px"}},{children:[t(d,e({sx:{width:36,height:36,borderRadius:"8px",bgcolor:"#DBEAFE",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0}},{children:i("svg",e({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#2563EB",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[t("circle",{cx:"12",cy:"12",r:"2"}),t("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]}))})),i(d,e({sx:{flex:1,minWidth:0}},{children:[t(m,e({sx:{fontSize:"0.875rem",fontWeight:600,color:"#1E3A5F",mb:"2px"}},{children:mo.title})),t(m,e({sx:{fontSize:"0.75rem",color:"#2563EB",mb:"8px"}},{children:mo.description})),i(d,e({sx:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"}},{children:[mo.inheritedText&&i(d,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px",display:"inline-flex",alignItems:"center",gap:"4px"}},{children:[i("svg",e({width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},{children:[t("polyline",{points:"15 3 21 3 21 9"}),t("path",{d:"M21 3L9 15"}),t("path",{d:"M3 21l6-6"})]})),mo.inheritedText]})),i(d,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[mo.rulesCount," rules"]})),i(d,e({component:"span",sx:{fontSize:"0.7rem",color:"#475569",bgcolor:"#F1F5F9",border:"1px solid #E2E8F0",borderRadius:"4px",px:"6px",py:"2px"}},{children:[mo.tiersCount," Tiers"]}))]}))]}))]})):so.genre?null:t(d,e({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",opacity:.4,py:6,gap:1}},{children:t(m,e({sx:{fontSize:"0.75rem",color:"#94A3B8"}},{children:"Select a genre to load the matching scope"}))}))})),so.genre&&i(l,{children:[i(m,e({sx:{fontSize:"1rem",fontWeight:600,mb:.5,color:"#19213D"}},{children:["Select an Existing Station from the “",so.genre,"” Scope"," ",t(m,e({component:"span",sx:{fontSize:"1rem",fontWeight:400,color:"#64748B"}},{children:"(Optional)"}))]})),i(m,e({sx:{fontSize:"0.75rem",color:"#64748B",mb:"12px"}},{children:["Please select an existing station under the “",so.genre,"” category to copy its learnings."]})),i("div",e({className:B.searchWrapper,style:{marginBottom:"12px"}},{children:[t("input",{type:"text",value:xe,onChange:function(e){return ve(e.target.value)},placeholder:"Search for station...",className:B.searchInput}),t(v,{className:B.searchIcon,size:16})]})),i(d,e({sx:{display:"flex",flexDirection:"column",gap:2}},{children:[we&&t(z,{}),!we&&0===fe.length&&Se.trim()&&i(m,e({sx:{fontSize:"0.875rem",color:"#64748B",textAlign:"center",py:4}},{children:['No scopes found matching "',Se,'".']})),!we&&fe.map(function(o){return t(D,e({},o,{isSelected:ze===o.id,onSelect:function(e){var o;Oe(ze===e?null!==(o=null==mo?void 0:mo.id)&&void 0!==o?o:null:e)}}),o.id)})]}))]})]}))]}))}))]})),i(d,e({sx:{p:"12px 20px",borderTop:"1px solid #F0F2F5",display:"flex",justifyContent:"flex-end",gap:2,bgcolor:"#fff"}},{children:[t("button",e({onClick:go,disabled:Ie,style:{padding:"7px 10px",borderRadius:"6px",color:"#64748B",border:"1px solid #E2E8F0",backgroundColor:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500}},{children:"Cancel"})),t("button",e({onClick:function(){return o(void 0,void 0,void 0,function(){var o,i,t,l,a,s,c,u,p,d,m,f,h,g,x,v,b,S,C,w,E,z,O;return r(this,function(r){switch(r.label){case 0:if(!$||!ze)return console.error("[StationOnboard] Missing required data for onboarding"),[2];if(j.getState().backwardCompatibility&&"approval_required"===Xe&&0===$e.length&&0===ro.length)return lo("Please select at least one approver or approver group."),setTimeout(function(){var e;null===(e=Ke.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},50),[2];lo(""),o=mo?n([mo],fe,!0):fe,i=o.find(function(e){return e.id===ze}),null==i?void 0:i.isCopy,Ae(!0),Le(0),t=null,r.label=1;case 1:return r.trys.push([1,3,,4]),c=j.getState().backwardCompatibility,l=c?{topic:"customRuleSet",customScopeGroupName:L.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:$.station_name||"New Station",parentScopeId:null,customScopeName:$.station_name||"New Station",customScopeId:y(),createByName:(null==Me?void 0:Me.firstname)||"System",createdBy:(null==Me?void 0:Me.email)||"system@audacy.com",scopeType:"Station",approvalRequired:"approval_required"===Xe,appsecData:{application:null==Ze?void 0:Ze.applicationId,module:null==Ze?void 0:Ze.moduleId,roles:n(n([],"approval_required"===Xe?[{users:$e.map(function(e){return e.email}),groups:ro.map(function(e){return e._id}),role:null!==(x=null===(g=Ye.find(function(e){return"Learning Manager"===e.name}))||void 0===g?void 0:g._id)&&void 0!==x?x:""}]:[],!0),[{users:[null==Me?void 0:Me.email],groups:[],role:null!==(b=null===(v=Ye.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===v?void 0:v._id)&&void 0!==b?b:""}],!1)}}:{topic:"customRuleSet",scope_reference_id:null,scopeDescription:"demo",parentScopeId:null,scopeName:$.station_name||"New Station",scopeReferenceMetadata:{},applicationMappingId:X},console.log("[StationOnboard] Step 1: Creating rule set with payload:",l),[4,k(l,J)];case 2:if(a=r.sent(),!(t=null===(S=null==a?void 0:a.data)||void 0===S?void 0:S.scopeId))throw new Error("Failed to create scope - no scopeId returned");return console.log("[StationOnboard] Step 1 Complete: Created scope with ID:",t),Le(1),[3,4];case 3:return s=r.sent(),console.error("[StationOnboard] Error creating rule set:",s),null===(C=Pe.current)||void 0===C||C.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to create rule set. Please try again."}),Ae(!1),Le(0),[2];case 4:return r.trys.push([4,6,,11]),c=j.getState().backwardCompatibility,u=e(e({market:$.market,region:$.region},c?{}:{timezone:so.timezone}),{primetime_windows:so.primeTime,genre:so.genre,station_type:""===so.type?null:so.type,low_sellout_configurations:"Low Sellout"===so.type?so.lowSelloutConfig:null,ruleset_id:t,station_guid:$.station_guid,station_name:$.station_name||"New Station"}),console.log("[StationOnboard] Step 2: Updating station with payload:",u),[4,T(u)];case 5:return r.sent(),console.log("[StationOnboard] Step 2 Complete: Station updated"),Le(2),[3,11];case 6:p=r.sent(),console.error("[StationOnboard] Error updating station, rolling back rule set:",p),409===p.status?(null===(w=Pe.current)||void 0===w||w.show({severity:"error",life:2500,summary:"Error updating station",detail:"Station already Onboarded."}),ee(null),Oe(null),qe(""),co(function(o){return e(e({},o),{region:""})})):null===(E=Pe.current)||void 0===E||E.show({severity:"error",life:2500,summary:"Error updating station",detail:"Please try again."}),r.label=7;case 7:return r.trys.push([7,9,,10]),[4,F(t,J)];case 8:return r.sent(),console.log("[StationOnboard] Rollback complete: Deleted rule set",t),[3,10];case 9:return d=r.sent(),console.error("[StationOnboard] Failed to rollback rule set deletion:",d),[3,10];case 10:return Ae(!1),Le(0),[2];case 11:return r.trys.push([11,13,,14]),m=null!==ze&&ze!==(null==mo?void 0:mo.id),f={source_scope_id:m?ze:null!==(z=null==mo?void 0:mo.id)&&void 0!==z?z:ze,target_scope_id:t,is_copy_parent_variant_id:m},console.log("[StationOnboard] Step 3: Inheriting scope with payload:",f),[4,_(f)];case 12:return r.sent(),console.log("[StationOnboard] Step 3 Complete: Scope inherited"),Le(3),[3,14];case 13:return h=r.sent(),console.error("[StationOnboard] Error inheriting scope (no rollback):",h),null===(O=Pe.current)||void 0===O||O.show({severity:"error",life:3e3,summary:"Error",detail:"Failed to apply rule template. Please try again."}),Ae(!1),Le(0),[2];case 14:return Ge.current=t,console.log("[StationOnboard] Onboarding completed successfully!"),[2]}})})},disabled:!vo||Ie,style:{padding:"7px 10px",borderRadius:"6px",border:"none",backgroundColor:vo?"#2563EB":"#BFDBFE",color:"#fff",cursor:vo&&!Ie?"pointer":"not-allowed",fontSize:"14px",fontWeight:500,display:"flex",alignItems:"center",gap:"7px"}},{children:i(l,Ie?{children:[t(g,{size:16,color:"inherit"}),t("span",{children:"Onboarding..."})]}:{children:[t("span",{children:"Onboard Station"}),t(b,{size:16})]})}))]}))]}))};export{H as default};
2
2
  //# sourceMappingURL=StationOnboardModal.js.map
@@ -1,2 +1,2 @@
1
- import e from"../../../node_modules/style-inject/dist/style-inject.es.js";var r={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};e(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}");export{r as default};
1
+ import e from"../../../node_modules/style-inject/dist/style-inject.es.js";var r={sidebar:"Sidebar-module_sidebar__BhVQw",tabsContainer:"Sidebar-module_tabsContainer__n542w",tabsWrapper:"Sidebar-module_tabsWrapper__z6rAx",tab:"Sidebar-module_tab__79tnm",tabActive:"Sidebar-module_tabActive__amUJ5",searchContainer:"Sidebar-module_searchContainer__KMtRV",searchWrapper:"Sidebar-module_searchWrapper__4ejma",searchInputWrapper:"Sidebar-module_searchInputWrapper__VI9Qk",searchIcon:"Sidebar-module_searchIcon__iyv9p",searchInput:"Sidebar-module_searchInput__oVmKU",searchRightContainer:"Sidebar-module_searchRightContainer__JZf8q",searchCountBadge:"Sidebar-module_searchCountBadge__JdOCA",searchClearButton:"Sidebar-module_searchClearButton__TCsGU",filterButton:"Sidebar-module_filterButton__OA1Bn",divider:"Sidebar-module_divider__EIZV1",content:"Sidebar-module_content__iG2Ya",section:"Sidebar-module_section__ChTDq",sectionTitle:"Sidebar-module_sectionTitle__EC2Bt",sectionList:"Sidebar-module_sectionList__TErRr",createButtonContainer:"Sidebar-module_createButtonContainer__EECqj",createButton:"Sidebar-module_createButton__wE7-a",emptyContent:"Sidebar-module_emptyContent__TV90P"};e(".Sidebar-module_sidebar__BhVQw{background-color:#fff;border-right:1px solid #e3e6ea;display:flex;flex-direction:column;height:calc(100vh - 140px);overflow:hidden;padding-top:1.25rem;position:relative;width:fit-content;width:340px}.Sidebar-module_tabsContainer__n542w{margin-bottom:1.25rem;padding:0 1.25rem}.Sidebar-module_tabsWrapper__z6rAx{background-color:#f3f4f6cc;border-radius:.5rem;display:grid;gap:.25rem;grid-template-columns:1fr 1fr;padding:.25rem}.Sidebar-module_tab__79tnm{align-items:center;background:#0000;border:none;border-radius:.375rem;color:#64748b;cursor:pointer;display:flex;font-size:.875rem;font-weight:600;gap:.5rem;justify-content:center;padding:.5rem .75rem;transition:all .2s}.Sidebar-module_tab__79tnm:hover{color:#2563eb}.Sidebar-module_tabActive__amUJ5{background-color:#fff;box-shadow:0 1px 2px 0 #0000000d;color:#2563eb;font-weight:700}.Sidebar-module_searchContainer__KMtRV{margin-bottom:1rem;padding:0 1.25rem}.Sidebar-module_searchWrapper__4ejma{display:flex;gap:.5rem}.Sidebar-module_searchInputWrapper__VI9Qk{align-items:center;display:flex;flex:1;position:relative;width:100%}.Sidebar-module_searchIcon__iyv9p{color:#9ca3af;left:.75rem;position:absolute;top:50%;transform:translateY(-50%)}.Sidebar-module_searchInput__oVmKU{background-color:#fff;border:1px solid #f0f2f5;border-radius:.5rem;box-shadow:0 1px 2px 0 #0000000d;font-size:.875rem;outline:none;padding:.5rem 1rem .5rem 2.25rem;transition:all .2s;width:100%}.Sidebar-module_searchInput__oVmKU:focus{border-color:#2563eb;box-shadow:0 0 0 2px #2563eb33}.Sidebar-module_searchInput__oVmKU::placeholder{color:#9ca3af}.Sidebar-module_searchRightContainer__JZf8q{align-items:center;display:flex;gap:.5rem;position:absolute;right:1rem;top:50%;transform:translateY(-50%)}.Sidebar-module_searchCountBadge__JdOCA{background-color:#fde047;border-radius:.25rem;color:#374151;font-size:.75rem;font-weight:500;padding:.125rem .375rem}.Sidebar-module_searchClearButton__TCsGU{align-items:center;background:#0000;border:none;color:#9ca3af;cursor:pointer;display:flex;margin:0;outline:none;padding:0;transition:color .2s ease}.Sidebar-module_searchClearButton__TCsGU:hover{color:#4b5563}.Sidebar-module_filterButton__OA1Bn{background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;cursor:pointer;padding:.5rem;transition:background-color .2s,border-color .2s}.Sidebar-module_filterButton__OA1Bn:hover{background-color:#f0f2f5}.Sidebar-module_filterButton__OA1Bn svg{color:#19213d}.Sidebar-module_divider__EIZV1{background-color:#f0f2f5;height:1.5px;margin:0 1.25rem 1rem;width:100%}.Sidebar-module_content__iG2Ya{flex:1;overflow-y:auto;padding:0 1.25rem}.Sidebar-module_content__iG2Ya::-webkit-scrollbar{width:4px}.Sidebar-module_content__iG2Ya::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.Sidebar-module_section__ChTDq{margin-bottom:1.5rem}.Sidebar-module_sectionTitle__EC2Bt{color:#19213d;font-size:.875rem;font-weight:600;margin-bottom:.75rem}.Sidebar-module_sectionList__TErRr{display:flex;flex-direction:column;gap:.75rem}.Sidebar-module_createButtonContainer__EECqj{background-color:#fff;border-top:1px solid #e5e7eb;bottom:0;box-shadow:0 -4px 20px #0000000d;left:0;padding:1rem;position:absolute;width:100%;z-index:50}.Sidebar-module_createButton__wE7-a{align-items:center;background-color:#f7f8fa;border:1px solid #f0f2f5;border-radius:.5rem;color:#19213d;cursor:pointer;display:flex;font-size:.75rem;font-weight:500;gap:.5rem;justify-content:center;padding:.75rem;transition:all .2s;width:100%}.Sidebar-module_createButton__wE7-a:hover{background-color:#f3f4f6;box-shadow:0 1px 2px 0 #0000000d}.Sidebar-module_createButton__wE7-a:active{transform:scale(.99)}.Sidebar-module_emptyContent__TV90P{align-items:center;color:#9ca3af;display:flex;flex-direction:column;font-size:.875rem;height:10rem;justify-content:center}");export{r as default};
2
2
  //# sourceMappingURL=Sidebar.module.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LearningManagement.d.ts","sourceRoot":"","sources":["../../../../../src/features/LearningManagement/LearningManagement.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAWrC,OAAoB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA+E9D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAA;IACD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,qBAA2B,EAC5B,EAAE,uBAAuB,2CA+iBzB;AAED,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"LearningManagement.d.ts","sourceRoot":"","sources":["../../../../../src/features/LearningManagement/LearningManagement.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAWrC,OAAoB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAgF9D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,oBAAoB,EAAE,MAAM,CAAC;KAC9B,CAAA;IACD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,UAAU,EACV,kBAAkB,EAClB,qBAA2B,EAC5B,EAAE,uBAAuB,2CAujBzB;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface RenameScopeModalProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ onSave: (newName: string) => Promise<void>;
6
+ initialName?: string;
7
+ }
8
+ declare const RenameScopeModal: React.FC<RenameScopeModalProps>;
9
+ export default RenameScopeModal;
10
+ //# sourceMappingURL=RenameScopeModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenameScopeModal.d.ts","sourceRoot":"","sources":["../../../../../../src/features/LearningManagement/RuleContent/RenameScopeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAgJrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"StationOnboardModal.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAgEpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAg3B3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"StationOnboardModal.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/LearningManagement/components/StationOnboarding/StationOnboardModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAqEpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,QAAA,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAk+B3D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-llm-studio/instant-learning",
3
- "version": "0.1.1-alpha.65",
3
+ "version": "0.1.1-alpha.67",
4
4
  "author": "Devesh Patel",
5
5
  "description": "",
6
6
  "license": "MIT",