"use strict";(self.webpackChunk_postman_app_scratchpad=self.webpackChunk_postman_app_scratchpad||[]).push([[9],{8136:function(e,t,a){a.r(t),a.d(t,{default:function(){return S}});var n=a(526),i=a.n(n),r=a(1),l=a(440),o=a(1539),s=a(3272),d=a(4829),u=a(3726),c=a(4634),f=a(6485),m=a(4588),p=a(3109),E=a(8137),v=a(5234),y=a(5256),b=a(5257),g=a(8138),I=a(8139),h=a(8141);a(5246);function S(e,t){const a=(0,s.observer)(({controller:a,editorId:n})=>{const s=(0,o.toJS)(a.itemState.get("item")),{error:S,isLoading:C,isActive:R}=a.tabState,T=!1,[O,_]=r.useState({}),A=(0,r.useMemo)(()=>{return(e=a.update.bind(a)).path=(t,a)=>{e(e=>{void 0===a?i().unset(e,t):i().set(e,t,a)})},e;var e},[a]),D=(0,r.useCallback)(()=>{a.cacheUpdatesBuffer()},[a]),L=Object.freeze((0,g.default)({type:pm.runtime.agent.stat.type,version:pm.runtime.version,isReady:pm.runtime.agent.isReady})),N=Object.freeze((0,g.default)({isActive:R,isOffline:a.isOffline,isReadOnly:a.isReadOnly})),k=(0,m.resolveStoreInstance)(f.default).get("editor.requestEditorLayoutName");if(S===E.default.DeletedEntity)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,type:"deleted",hasToCapitalize:!1});if(S===E.default.NoHistoryPermission)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,icon:e.config.icon,title:"You don't have view permission",message:`Only team members can view this ${e.config.title} from history of this workspace.`,hasToCapitalize:!1});if(S)return r.createElement(u.default,{userFriendlyEntityName:e.config.title,hasToCapitalize:!1});if(C)return r.createElement(d.default,null);return r.createElement(v.AgentContext.Provider,{value:L,key:s.id},r.createElement(c.default,{collectionId:null},r.createElement(y.TabContext.Provider,{value:N},r.createElement(b.LayoutContext.Provider,{value:k},function(){var i;return r.createElement(l.default,{direction:"column",height:"100%"},r.createElement(I.default,{state:s,isSaved:T,historyId:a instanceof h.default&&a.historyId||null,feedbackURL:e.config.feedbackURL,docsURL:e.config.docsURL,saveDisabledReason:a.saveDisabledReason,saveAsDisabledReason:a.saveAsDisabledReason,renameOnMount:null===(i=a.context)||void 0===i?void 0:i.rename,tabId:a.getTabId(),cacheUpdatesBuffer:D}),r.createElement(t,{state:s,update:A,agent:L,tab:N,historyEvents:a instanceof h.default?a.historyEvents:[],setContextData:e=>_(Object.assign(Object.assign({},O),e)),collectionId:null,promoteTab:()=>p.default.promoteEditor({id:n}),controller:a}))}()))))});return class extends r.Component{render(){return r.createElement(a,{controller:this.props.controller,editorId:this.props.id})}}}},8138:function(e,t,a){a.r(t),a.d(t,{default:function(){return i}});var n=a(1);function i(e){return n.useMemo(()=>Object.assign({},e),[...Object.values(e)])}},8139:function(e,t,a){a.r(t),a.d(t,{default:function(){return O}});var n=a(1),i=a(30),r=a(512),l=a(440),o=a(5049),s=a(131),d=a(3560),u=a(3720),c=a(6286),f=a(6288),m=a(5712),p=a(5722),E=a(5719),v=a(2974),y=a(5244),b=a(5233),g=a(5245),I=a(5246),h=a(8140),S=a(5256),C=a(3265),R=a(6868);(0,i.default)(d.Dropdown)`
  & .btn-group > .btn {
    min-width: var(--size-s);
    height: var(--size-m);
    padding: var(--spacing-s) var(--spacing-xs);
    margin-left: var(--border-width-default);
  }
`;const T=(0,i.default)(u.default)`
  &.entity-tab-header {
    border-bottom: 0;
  }
`;function O({state:e,isSaved:t,historyId:a,saveDisabledReason:i,saveAsDisabledReason:d,renameOnMount:u,tabId:O,cacheUpdatesBuffer:_}){var A;const D=(null===(A=pm.ECItemRegistry.getConfig(e.type))||void 0===A?void 0:A.title)||"item",L=i||`Save ${D}`,N=d||`Save ${D} to a collection`,{isOffline:k,isReadOnly:U}=(0,S.default)(),[w,x]=n.useState(!1),B=(0,h.default)(),M=n.useRef(null),P=Boolean(null!==a);n.useEffect(()=>{var e;u&&(null===(e=M.current)||void 0===e||e.handleEditName())},[]);const z=n.useMemo(()=>{var a;const n=[];if(t){n.push({type:e.type,id:e.id,name:e.title});let t=null===(a=I.default.cacheAPI.get(e.id))||void 0===a?void 0:a.parent;for(;t;){const{parent:e}=I.default.getParent(t);n.unshift({type:e.type,id:e.id,name:e.title||""}),t=e.parent}}return n},[e]),F=n.useCallback(()=>pm.mediator.trigger("showSignInModal",{userFlow:R.USER_FLOW.REQUEST_SAVE,subtitle:p.SAVE_REQUEST_SIGNIN_MODAL_SUBTITLE}),[]),j=(n.useCallback(()=>pm.mediator.trigger("showSignInModal",{userFlow:R.USER_FLOW.REQUEST_SAVE,subtitle:p.SAVE_REQUEST_SIGNIN_MODAL_SUBTITLE}),[]),n.useCallback(({id:e,type:t})=>{var a;t===y.COLLECTION?g.default.openInTab(e):null===(a=pm.ECItemRegistry.getSDK(t))||void 0===a||a.openInTab(e)},[])),G=n.useCallback(({id:e,type:t})=>t===y.COLLECTION?{routeIdentifier:"build.collection",routeParams:{cid:e},queryParams:null}:pm.ECItemRegistry.getSDK(t)?{routeIdentifier:pm.ECItemRegistry.getSDK(t).openSavedIdentifier,routeParams:{ecid:e},queryParams:{}}:null,[]),K=n.useCallback(t=>{if(w)return;x(!0);pm.ECItemRegistry.getSDK(e.type).menuActionHandler(e.id,b.ItemAction.RENAME,{name:t}).then(()=>{B()&&x(!1)})},[w,e.type,e.id]);n.useCallback(()=>{pm.ECItemRegistry.getSDK(e.type).menuActionHandler(e.id,b.ItemAction.DELETE)},[e.type,e.id]),t?n.createElement(r.default,{text:"Save",type:"secondary",icon:n.createElement(s.default,null),onClick:F,isDisabled:Boolean(i),tooltip:L}):n.createElement(r.default,{text:"Save",type:"secondary",icon:n.createElement(s.default,null),onClick:F,isDisabled:Boolean(d),tooltip:N});return n.createElement(T,{name:e.title,ref:M,path:z.length?z:null,entityType:a?`ech:${e.type}`:`ec:${e.type}`,entityUID:a||e.id,isEntityEditable:t&&!k&&!U&&!w,onBreadCrumbItemClick:j,onSubmit:K,leftMetaComponent:()=>n.createElement(m.default,{activeValue:e.type,tabId:O,canSwitch:!t&&!P,beforeSwitch:()=>_()}),renderActions:()=>n.createElement(l.default,{alignItems:"center",gap:"spacing-s"},(()=>{const e=n.createElement(r.default,{icon:n.createElement(s.default,null),text:"Save",type:"tertiary"});return v.default.isEnabled?n.createElement(o.default,{placement:"bottom-end",padding:"spacing-xs",maxWidth:"350px",trigger:e,pointer:"true"},n.createElement(E.default,{title:p.GENERIC_SIGNIN_MODAL_TITLE,subtitle:p.GENERIC_SIGNIN_MODAL_SUBTITLE})):n.createElement(r.default,{icon:n.createElement(s.default,null),text:"Save",type:"tertiary",onClick:F})})(),C.default.isUseBrowserTabsActive()&&n.createElement("div",{className:"environment-container"},n.createElement(c.default,{selectorWidth:130,useBrowserTabs:!0}),n.createElement("div",{className:"environment-splitter"}),n.createElement(f.default,{useBrowserTabs:!0}))),breadCrumbRouteConfig:G})}},8140:function(e,t,a){a.r(t),a.d(t,{default:function(){return i}});var n=a(1);function i(){const e=n.useRef(!0);return n.useEffect(()=>()=>{e.current=!1},[]),n.useCallback(()=>e.current,[])}}}]);