import{g as Se}from"./chunk-UTLWAHS5.js";import{a as te,c as _e}from"./chunk-OMLPHRMQ.js";import{Bc as Zt,Cc as we,Ec as ke,Fc as $e,ia as vo}from"./chunk-QDC5IYIV.js";import{f as Wt}from"./chunk-JARCPJ4B.js";import{Aa as Kt,h as Yt,ka as Jt,y as Qt}from"./chunk-YMMSJEOM.js";import{C as U,P as Vt,U as Gt,ja as Xt,mb as $t,n as xe,nb as qt,ob as jt,pb as Be}from"./chunk-JNX2JEHJ.js";import{b as Ke}from"./chunk-5QCWKDGC.js";import{a as zt}from"./chunk-AL2TIXGN.js";import{i as kt}from"./chunk-JSNGRGOK.js";import{Qb as _t,ta as De}from"./chunk-2IRZ7GAJ.js";import{c as Ae}from"./chunk-7AT2MAST.js";import{b as Re}from"./chunk-VEEXP5AH.js";import{V as Bt,W as wt,k as ue}from"./chunk-2YDBBK6X.js";import{g as Ft}from"./chunk-NBCBELTC.js";import{d as Ht}from"./chunk-UFKU5R6F.js";import{d as Je}from"./chunk-HTT5P6K7.js";import{b as le}from"./chunk-PRUBWBC3.js";import{B as Ut}from"./chunk-NWRPA7VR.js";import{b as Lt}from"./chunk-PSPKVWFT.js";import{k as Pt}from"./chunk-HTJEHK2Y.js";import{h as Mt}from"./chunk-PDEHFL4P.js";import{a as Oe}from"./chunk-R537MJ5L.js";import{c as F,d as Me}from"./chunk-LBA7D2MT.js";import{p as fe}from"./chunk-CVZ6RPO4.js";import{f as G}from"./chunk-DCSKFP4R.js";import{ea as Ne,ga as Ot}from"./chunk-E5OZNRXW.js";import{l as xt,n as Eo}from"./chunk-2Z3776CO.js";import{i as R,l as j,o as ne,q as Xe}from"./chunk-66FTBOJ5.js";import{a as ye}from"./chunk-HWBBAF7Z.js";import{e as Ce,p as Rt}from"./chunk-4CA2PWQJ.js";import{m as M,s as y,w as L}from"./chunk-UOZCAK33.js";import{a as p}from"./chunk-5KNVSQHS.js";import{a as ee}from"./chunk-S27WBILL.js";import{$b as de,D as B,E as pe,Ff as At,Gf as ze,Kf as Qe,Le as Et,N as Tt,Nc as a,Q as It,T as ho,Ze as vt,a as D,ac as bt,b as q,bf as Ct,ch as X,d as St,h as l,hf as Nt,k as gt,lf as Q,n as Io,pg as ve,qd as ht,sg as Dt,v as bo}from"./chunk-63KZMW3E.js";a();L();a();j();var qe=l(p()),je=o=>{var r=o,{className:e}=r,t=St(r,["className"]);return(0,qe.jsx)("span",{className:e,style:{verticalAlign:"text-top"},children:(0,qe.jsx)(R,D({},t))})};var ie=l(p()),Xo=({targetTableName:e,targetTablePrimaryColumn:{type:t,typeOptions:o},onShowErrorMessage:r,className:s})=>{let c=M();Oe(()=>{r()});let d=Ot({type:t,typeOptions:o},c);return(0,ie.jsx)(G,{color:"red",className:s,children:(0,ie.jsx)(y,{defaultMessage:[{type:1,value:"warningIcon"},{type:0,value:" Only tables that have a "},{type:1,value:"columnDisplayName"},{type:0,value:" field can be synced to "},{type:1,value:"targetTableIcon"},{type:0,value:" "},{type:8,value:"strong",children:[{type:1,value:"targetTableName"}]},{type:0,value:"."}],id:"nyhlog",values:{warningIcon:(0,ie.jsx)(je,{name:"Warning",fillColor:Se.RED_BRIGHT}),columnDisplayName:d,targetTableIcon:(0,ie.jsx)(je,{name:"Table",fillColor:Se.RED_BRIGHT}),strong:S=>(0,ie.jsx)("span",{className:"strong",children:S}),targetTableName:e}})})};a();X();var be=l(ee());L();a();a();L();j();a();var ge="16rem";var Z=l(p()),Ze=({iconName:e,iconColor:t,tableName:o})=>(0,Z.jsxs)("div",{className:"flex items-center pb1-and-half border-bottom border-darken2",style:{width:ge},children:[(0,Z.jsx)("div",{className:"flex items-center mr-half",children:(0,Z.jsx)(R,{name:e,fillColor:t})}),(0,Z.jsx)(G,{size:"large",shouldTruncate:!0,children:(0,Z.jsx)(y,{defaultMessage:[{type:0,value:"Field in "},{type:8,value:"strong",children:[{type:1,value:"tableName"}]}],id:"kVJ33o",values:{strong:r=>(0,Z.jsx)("span",{className:"strong",children:r}),tableName:o}})})]});var Te=l(p()),eo=({sourceViewName:e,sourceViewIconConfig:{name:t,fillColor:o},targetTableName:r})=>(0,Te.jsxs)("div",{className:"flex justify-between mb2-and-half mr2",children:[(0,Te.jsx)(Ze,{iconName:t,iconColor:o,tableName:e}),(0,Te.jsx)(Ze,{iconName:"Table",tableName:r})]});a();var oo=l(ye());L();j();a();j();var Ie=l(p()),et=({iconName:e,columnName:t})=>(0,Ie.jsxs)("div",{className:"flex items-center",children:[(0,Ie.jsx)(R,{name:e}),(0,Ie.jsx)(G,{className:"ml1",children:t})]});var h=l(p()),to={defaultMessage:[{type:0,value:"No field selected"}],id:"rCu4jX"},tt=({className:e,selectedSourceColumnId:t,sourceColumnOptions:o,targetColumnName:r,targetColumnDisplayType:s,isExternalFieldIdMapped:c,onSelectSourceColumn:d})=>{let S=M(),{displayTypeIcon:C}=Ke(s),N=[null,...o.keys()],u=i=>!!i&&c(i)&&i!==t,g=(s==="select"||s==="multiSelect")&&!!t,n=o.size>0;return(0,h.jsxs)("div",{className:(0,oo.default)("flex items-center",e),"data-testid":"map-source-to-target-row",children:[(0,h.jsx)("div",{style:{width:ge},children:n?(0,h.jsx)(Ut,{items:N,onItemSelect:d,selectedItem:t,toggleButtonEmptyState:S.formatMessage(to),itemRenderer:i=>{if(i.item===null)return(0,h.jsx)(G,{children:(0,h.jsx)(y,D({},to))});let A=o.get(i.item),{displayTypeIcon:E}=Ke(A.displayType);return(0,h.jsx)(fe,{content:S.formatMessage({defaultMessage:[{type:0,value:"Field has already been mapped"}],id:"2ALgXr"}),disabled:!u(i.item),placement:"left-end",children:(0,h.jsx)("div",{children:(0,h.jsx)(et,{iconName:E,columnName:A.name})})})},isItemDisabled:u,getItemsForSearchQuery:(i,A)=>{let E=A.trim().toLowerCase();return i.filter(V=>{var J;if(V===null)return A==="";{let I=(J=o.get(V))==null?void 0:J.name;return I==null?void 0:I.toLowerCase().includes(E)}})}}):(0,h.jsx)(G,{color:"quiet",children:(0,h.jsx)(y,{defaultMessage:[{type:0,value:"No compatible field types found"}],id:"R6H01x"})})}),(0,h.jsx)("div",{className:"flex items-center mx2-and-half",children:(0,h.jsx)(R,{name:"ArrowRight",fillColor:Se.DARK})}),(0,h.jsxs)("div",{className:"flex items-center",children:[(0,h.jsx)("div",{className:"flex items-center p1 rounded rounded-big border border-darken2 colors-background-subtler",style:{height:36,width:ge},children:(0,h.jsx)(et,{iconName:C,columnName:r})}),(0,h.jsx)("div",{className:"flex items-center pl1",children:(0,h.jsx)(fe,{content:(0,h.jsx)("div",{style:{width:200},children:(0,h.jsx)(y,{defaultMessage:[{type:0,value:"The select options for this field will be overwritten. All filtering and sorting that depends on those options will be reset."}],id:"PTcu05"})}),disabled:!g,placement:"auto",children:(0,h.jsx)("div",{className:"flex items-center",children:(0,h.jsx)(R,{name:"warning",fillColor:g?"grey":"white"})})})})]})]})};var H=l(p()),wr=({targetTableName:e,targetTablePrimaryColumn:t,targetTableNonPrimaryColumns:o,sourceViewName:r,sourceViewIconConfig:s,sourceViewColumnsById:c,onColumnMappingChange:d,columnMapping:S,isExternalFieldIdMapped:C,shouldShowPrimaryFieldLabel:N=!0,shouldShowRecommendedLabel:u=!0,primaryTargetRowClassName:f="pb2-and-half",nonPrimaryTargetRowClassName:g="pb1-and-half",shouldShowNonMappableTargetTableNonPrimaryColumns:n=!1})=>{var J;let i=(0,be.useMemo)(()=>{var _,ce;let I=new Map;for(let[W,Y]of ve(c)){let $=(_=I.get(Y.type))!=null?_:new Map;$.set(W,{name:Y.name,displayType:Ne(Y),canBePrimary:Ae(Y)}),I.set(Y.type,$)}let P=new Map,v=new Set([t.type,...o.map(W=>W.type)]);for(let W of v){let Y=De(W),$=(ce=P.get(W))!=null?ce:new Map;for(let Ye of Y){let x=I.get(Ye);x==null||x.forEach((T,z)=>{$.set(z,T)})}P.set(W,$)}return P},[c,o,t.type]),[A,E]=vt.default(o,I=>{var v;return((v=i.get(I.type))!=null?v:new Map).size>0}),V=n?[...A,...E]:A;return(0,H.jsx)(be.Fragment,{children:(0,H.jsxs)("div",{className:"p2-and-half flex flex-column overflow-hidden height-full width-full",children:[(0,H.jsx)(eo,{sourceViewName:r,sourceViewIconConfig:s,targetTableName:e}),N&&(0,H.jsx)(G,{className:"pb-half",size:"small",fontWeight:"strong",children:(0,H.jsx)(y,{defaultMessage:[{type:0,value:"Primary field"}],id:"g240xI"})}),(0,H.jsx)(tt,{className:f,selectedSourceColumnId:(J=S[t.id])!=null?J:null,sourceColumnOptions:new Map([...i.get(t.type)].filter(([I,P])=>P.canBePrimary)),targetColumnName:t.name,targetColumnDisplayType:Ne(t),onSelectSourceColumn:I=>d(t.id,I),isExternalFieldIdMapped:C}),V.length>0&&(0,H.jsxs)(be.Fragment,{children:[u&&(0,H.jsx)(G,{className:"pb-half",size:"small",fontWeight:"strong",children:(0,H.jsx)(y,{defaultMessage:[{type:0,value:"Other fields (recommended)"}],id:"n7th10"})}),(0,H.jsx)("div",{className:"flex flex-column overflow-auto","data-testid":"map-source-to-target-non-primary-columns",children:V.map(I=>{var P,v;return(0,H.jsx)(tt,{className:g,selectedSourceColumnId:(P=S[I.id])!=null?P:null,sourceColumnOptions:(v=i.get(I.type))!=null?v:new Map,targetColumnName:I.name,targetColumnDisplayType:Ne(I),onSelectSourceColumn:_=>d(I.id,_),isExternalFieldIdMapped:C},`upconvert-${I.id}-mapping-row`)})})]})]})})};a();var To=l(ee());L();a();var go=l(ye());Eo();var K=l(ee());L();a();X();X();var fo=l(ye());var ae=l(ee()),ut=l(ee());L();j();a();X();var so=l(ee()),co=l(ee());L();j();a();X();X();pe();Io();bo();ho();function ro(e){switch(e){case"contacts":case"calendar":case"jira":case"xml":return e;case"csv":case"pasteTable":case"excel":case"googleSheets":case"appleNumbers":case"access":case"asana":case"trello":case"coda":case"notion":case"smartsheet":case"monday":case"dropbox":case"json":case"box":case"facebook":case"googleDrive":throw new gt("not a block import source",{importSourceType:e});default:throw new Q(e)}}var ao=function(t,o){let r=Do(t),s=Dt(o)[r];return s?{blockId:s,slug:Ao(t),type:"publish"}:(Tt()||It()||(B.logger.warn("blockId not found for block name",{blockName:r}),B.stats.increment("airtable.client.block_lookup_by_name.fail")),null)};function Ao(e){switch(e){case"csvInplace":return"csv-import";case"contacts":return"contact-import";case"calendar":return"calendar-import";case"jira":return"jira";case"xml":return"xml-import";default:throw new Q(e)}}function Do(e){switch(e){case"csvInplace":return"CSV import";case"contacts":return"Contact import";case"calendar":return"Calendar import";case"jira":return"Jira Cloud";case"xml":return"XML import";default:throw new Q(e)}}a();X();L();j();a();var oe=l(p()),rt=({dialogToRenderOnClick:e,numSources:t,dataSourceType:o,applicationModel:r})=>{let s=M(),c;if(t<=0)c=s.formatMessage({defaultMessage:[{type:0,value:"View more..."}],id:"zx1iZi"});else switch(o){case"libraryTab":c=s.formatMessage({defaultMessage:[{type:1,value:"numSources"},{type:0,value:" more "},{type:6,value:"numSources",options:{one:{value:[{type:0,value:"data set"}]},other:{value:[{type:0,value:"data sets"}]}},offset:0,pluralType:"cardinal"},{type:0,value:"..."}],id:"IAD0Of"},{numSources:t});break;case"otherSourcesTab":c=s.formatMessage({defaultMessage:[{type:1,value:"numSources"},{type:0,value:" more "},{type:6,value:"numSources",options:{one:{value:[{type:0,value:"source"}]},other:{value:[{type:0,value:"sources"}]}},offset:0,pluralType:"cardinal"},{type:0,value:"..."}],id:"68+y/6"},{numSources:t});break;default:new Q(o)}return(0,oe.jsx)(U.Item,{"aria-label":c,onSelect:()=>{le(s,e)},svgClassName:"mr1-and-half",className:"new-table-menu-item-sync-redesign",icon:"BookOpen",children:(0,oe.jsxs)("div",{className:"flex items-center",children:[(0,oe.jsx)("span",{children:c}),(0,oe.jsx)("div",{className:"ml-auto flex items-center",children:(0,oe.jsx)(R,{className:"pl1 text-color-quiet ml-half",name:"chevronRight"})})]})},"more-sources")};a();X();function Pe(e){return e.isPackageConstructionApplication()?{airtableSharedView:{dataSourceType:"airtableSharedView",provider:Xt("airtableSharedView")}}:Nt(Be(),t=>t.dataSourceType)}a();var Le=l(p());function no(e,t,o){return(0,Le.jsx)(U.Item,{onSelect:t,className:o,children:(0,Le.jsx)("div",{className:"flex items-center",style:{marginLeft:"1px"},children:(0,Le.jsx)("span",{className:"truncate",children:e.name})})},`KEY_[${e.enterpriseAccountId}, ${e.publishedDatasetId}]`)}Me();a();bt();Rt();pe();var m=l(p()),lt=["csv","excel","googleSheets","pasteTable","appleNumbers","access","asana","trello","contacts","calendar","xml"],Mo=["airtableSharedView","csv","googleCalendar","googleSheets","excel","salesforce"],it=["csv","calendar","contacts","xml"],at=3,Fe=2;function st(e){return ht(ue,e)}function ct(e,t){var r,s;let o=te[e];if(o.category==="blockImport"){let c=ao(ro(e),t);if(!c&&!((s=(r=window.process)==null?void 0:r.env)!=null&&s.STORYBOOK))return null;o=D(D({},c),o)}return o}function Ro(e){var V;let{importSourceType:t,billingPlan:o,onSelect:r,svgClassName:s,className:c,icon:d,applicationModel:S}=e,C=M(),N=Pt(o),u=S.getHyperbaseModel().getInitData();B.assert(!Mt(u));let f=ct(t,u.blockHumanReadableNameByBlockId);if(f===null)return null;let n=f.category==="blockImport"?!N:!1,{getName:i,menuIconName:A}=f,E=i(C);return(0,m.jsx)(U.Item,{onSelect:()=>r(f),icon:(V=d!=null?d:A)!=null?V:void 0,className:c,svgClassName:s,"aria-label":E,children:(0,m.jsxs)("div",{className:"flex items-center",children:[(0,m.jsx)("span",{children:E}),n&&(0,m.jsx)("div",{className:"pl1 ml-auto",children:(0,m.jsx)(Yt,{scale:.75,refTag:de.NEW_TABLE_MEMU,granularRef:E})})]})},E)}function nt({style:e,children:t}){return(0,m.jsx)("li",{className:"text-size-small mx1-and-half mt2 truncate new-table-menu-heading line-height-4",style:e,role:"presentation",children:t})}function Oo(e,t){Et(async()=>{let o=B.id.generatePackageInstallationId(),r=t.id,s=t.getPackageReleaseId();F.track("packagesPlatform.install.click",{origin:"newTableMenu",packageInstallationId:o,packageId:r,packageReleaseId:s}),await Kt({packageInstallationId:o,params:{applicationId:e.id,packageId:r,packageReleaseId:s,customizationVariableInstantiatedValues:{},installationType:"table"}})})()}function lo({index:e}){let t=["60%","45%","80%"];return(0,m.jsx)(U.Item,{children:(0,m.jsx)("span",{className:"inline-block darken2 animate-pulse-opacity rounded-big",style:{height:"1cap",width:t[e%t.length]}})})}function Za({onCreateEmptyTableIfAllowed:e,onInstallTablePackageIfAllowed:t,menuButton:o,onSelectImportItem:r,onOpenSyncDialogIfAllowed:s,onClose:c,onOpen:d,placement:S,fallbackPlacements:C,menuSyncDialogOrigin:N,applicationModel:u,publishedDatasetsData:f,tablePackages:g,blockHumanReadableNameByBlockId:n}){let i=M(),[A,E]=(0,so.useState)(!1),V=_e(i),J=(0,m.jsx)(U.Item,{onSelect:e,className:"new-table-menu-item-sync-redesign","aria-label":i.formatMessage({defaultMessage:[{type:0,value:"Start from scratch"}],id:"NkCru9"}),children:(0,m.jsx)(y,{defaultMessage:[{type:0,value:"Start from scratch"}],id:"NkCru9"})},"create-empty"),I=Re(()=>u.getBillingPlanLive(),[u]),P=_t(I,"publishedDatasets"),v=u.shouldShowPublishedDatasetsFeature(),_=(x,T)=>{if(x==="libraryTab"&&v)return(0,m.jsx)($e,{applicationModel:u,userId:u.getCurrentSessionUserId(),onClose:ze.default,componentLibraryStateInfo:{state:"library",navSelection:"browse",browseTabNavSelection:"dataSets"}});{let z=[...P&&!v?["libraryTab"]:[],"otherSourcesTab"];return(0,m.jsx)(io,{onClose:ze.default,applicationModel:u,onSelectImportSource:me=>r(!1,me),onSelectSyncSource:me=>s("addSyncOrImportDialogOtherSources",me),publishedDatasetData:f,startingTab:x,origin:T,blockHumanReadableNameByBlockId:n,eligibleTabs:z})}},ce=Pe(u),W=Mo.map(x=>{if(st(x)){let T=ce[x];if(!T)return null;let z=(0,m.jsx)("div",{className:"mr1-and-half flex items-center text-gray",children:T.provider.getDataSourceTypeColorIcon(16,i)});return jt(x,I,T.provider,!1,me=>s(N,me),de.SYNC_SOURCE_MENU,i,z,"new-table-menu-item-sync-redesign")}else{let T=it.includes(x)?void 0:(0,m.jsx)("div",{className:"mr1-and-half flex items-center",children:V[x].getDialogIcon()});return(0,m.jsx)(Ro,{importSourceType:x,billingPlan:I,onSelect:z=>r(!0,z),className:"new-table-menu-item-sync-redesign",svgClassName:"mr1-and-half",icon:T,applicationModel:u},x)}}),Y=[];u.shouldShowPackagesFeature()&&(Y=[...g?g.slice(0,Fe).map(T=>(0,m.jsx)(U.Item,{onSelect:()=>{t(),Oo(u,T)},children:T.getName()},T.id)):Qe.default(Fe+1,T=>(0,m.jsx)(lo,{index:T},`package-loading-skeleton-${T}`)),...g?[(0,m.jsx)(U.Item,{icon:"BookOpen",onSelect:()=>E(!0),children:(0,m.jsxs)("div",{className:"flex items-center justify-between",children:[g.length>Fe?i.formatMessage({defaultMessage:[{type:1,value:"moreTablesCount"},{type:0,value:" more "},{type:6,value:"moreTablesCount",options:{one:{value:[{type:0,value:"table"}]},other:{value:[{type:0,value:"tables"}]}},offset:0,pluralType:"cardinal"},{type:0,value:"..."}],id:"lCt8rN"},{moreTablesCount:g.length-Fe}):i.formatMessage({defaultMessage:[{type:0,value:"View library..."}],id:"MU4KzS"}),(0,m.jsx)(R,{className:"pl1 text-color-quiet",name:"chevronRight"})]})},"table-overflow")]:[]]);let $=[];if(P){let x=f?ke(f.datasets).slice(0,at).filter(T=>T.type!=="data_table"||Ce("dataTableSyncSource")).map(T=>no(T,()=>{F.track("application.newTableMenu.verifiedData.dataset.click");let z=f.userProfileInfoByUserId[T.ownerId];B.assert(z,"ownerUserProfileInfo is undefined",{userId:T.ownerId}),le(i,(0,m.jsx)(we,{dataset:T,ownerUserProfileInfo:z,onClose:()=>{},applicationModel:u,shouldShowAddDatasetButton:!0}))},"new-table-menu-item-sync-redesign")):Qe.default(at+1,T=>(0,m.jsx)(lo,{index:T},`dataset-loading-skeleton-${T}`));$=[(0,m.jsx)(U.Divider,{className:"mx1-and-half"},"divider1"),(0,m.jsx)(nt,{children:v?(0,m.jsx)(y,{defaultMessage:[{type:0,value:"Add from library"}],id:"ZOmBtX"}):(0,m.jsx)(y,{defaultMessage:[{type:0,value:"Add from data library"}],id:"YGx6Dt"})},"add-dataset"),...x,...f?[(0,m.jsx)(rt,{numSources:f.datasets.length-at,dialogToRenderOnClick:_("libraryTab","newTableMenuMoreLibrarySourcesButton"),dataSourceType:"libraryTab",applicationModel:u},"more-sources-publishedDatasets")]:[]]}let Ye=Object.keys(ce).length+lt.length-W.length;return(0,m.jsxs)(co.Fragment,{children:[(0,m.jsx)(U,{menuButton:o,className:"new-table-menu-sync-redesign-text-color",menuListClassName:"p1",width:280,onClose:c,onOpen:d,placement:S,fallbackPlacements:C,children:[(0,m.jsx)(nt,{style:{marginTop:0},children:(0,m.jsx)(y,{defaultMessage:[{type:0,value:"Add a blank table"}],id:"o5B9N8"})},"add-blank"),J,...Y,...$,(0,m.jsx)(U.Divider,{className:"mx1-and-half"},"divider2"),(0,m.jsx)(nt,{children:(0,m.jsx)(y,{defaultMessage:[{type:0,value:"Add from other sources"}],id:"Wz/mey"})},"add-from-other-sources"),...W,(0,m.jsx)(rt,{numSources:Ye,dialogToRenderOnClick:_("otherSourcesTab","newTableMenuMoreOtherSourcesButton"),dataSourceType:"otherSourcesTab",applicationModel:u},"more-sources")]}),A?(0,m.jsx)($e,{applicationModel:u,userId:u.getCurrentSessionUserId(),onClose:()=>E(!1),componentLibraryStateInfo:{state:"library",navSelection:"browse",browseTabNavSelection:"tables"}}):null]})}a();X();var mt=l(ye());L();Xe();var Ee=l(p()),Ue=e=>`${e}px solid hsla(0, 0%, 0%, 0.1)`;function xo(e,t){switch(e){case"libraryTab":return t.formatMessage({defaultMessage:[{type:0,value:"Data library"}],id:"Rl0BQ+"});case"otherSourcesTab":return t.formatMessage({defaultMessage:[{type:0,value:"Other sources"}],id:"Wr5v48"});default:throw new Q(e)}}function mo(e){let t=M(),{currentTab:o,onTabChange:r,eligibleTabs:s}=e;return(0,Ee.jsx)("ul",{className:"flex list-style-none",style:{margin:"0 -2rem 0.5rem -2rem",padding:"0 2rem",borderBottom:Ue(1)},children:s.map(c=>{let d=c===o;return(0,Ee.jsx)("li",{children:(0,Ee.jsx)(ne,{as:"div",onClick:()=>{r(c)},className:(0,mt.default)("flex items-center py1-and-half big strong nowrap no-user-select focus-container hover-container",{"text-blue cursor-default border-bottom-thick border-blue":d,pointer:!d}),style:{marginBottom:d?-2:0,marginRight:"1.5rem"},"aria-label":c,children:(0,Ee.jsx)("span",{className:(0,mt.default)("parent-focus-visible",{"quiet parent-hover-unquiet":!d}),children:xo(c,t)})})},c)})})}a();L();Xe();j();Me();bt();var w=l(p()),dt="REQUEST_AN_INTEGRATION",He=24;function pt(e){return(0,w.jsxs)(ne,{as:"div",className:"py2-and-quarter text-size-large flex items-center px2 pointer sync-or-import-source-card focus-visible",onClick:e.onSelect,"aria-label":e.name,children:[e.icon,(0,w.jsx)("span",{className:"strong ml2 truncate",children:e.name}),e.badge&&(0,w.jsx)("div",{className:"pl1 ml-auto",children:e.badge})]})}function po(e){var f;let{sourceType:t,allowedTableSyncSourcesBySyncSourceType:o,applicationBillingPlan:r,onSelectImportSource:s,onSelectSyncSource:c,onCloseDialog:d,displayName:S,blockHumanReadableNameByBlockId:C}=e,N=M(),u=_e(N);if(t===dt)return(0,w.jsx)(pt,{name:N.formatMessage({defaultMessage:[{type:0,value:"Request an integration"}],id:"C+YOTL"}),icon:(0,w.jsx)(R,{name:"flag",size:He,className:"text-gray"}),onSelect:()=>{F.track("application.addSyncOrImportDialog.requestIntegration"),window.open($t,"_blank")}});if(st(t)){let g=o[t];if(!g)return null;let n=g.provider,{showPremiumBadge:i,showBetaBadge:A,minimumBillingPlanGrouping:E}=qt(t,r,n);return(0,w.jsx)(pt,{name:S!=null?S:N.formatMessage((f=n.dataSourceTypeMenuItemNameMessageDescriptor)!=null?f:n.dataSourceTypeDisplayNameMessageDescriptor),icon:(0,w.jsx)("div",{className:"flex items-center text-gray",children:n.getDataSourceTypeColorIcon(He,N)}),badge:i?(0,w.jsx)("div",{className:"pl1 ml-auto",children:(0,w.jsx)(Vt,{refTag:de.ADD_SYNC_OR_IMPORT_DIALOG,label:t,spacingClassName:"ml1",billingPlanGrouping:E})}):A?(0,w.jsx)("div",{className:"pl1 ml-auto",children:(0,w.jsx)(Gt,{})}):void 0,onSelect:()=>{d(),c(t)}})}else{let g=ct(t,C);if(g===null)return null;let n=it.includes(t)?(0,w.jsx)("div",{className:"flex items-center",children:(0,w.jsx)(R,{name:te[t].menuIconName,size:He-4,className:"text-gray"})}):(0,w.jsx)("div",{className:"flex items-center",children:u[t].getDialogIcon(He)});return(0,w.jsx)(pt,{name:S!=null?S:te[t].getName(N),icon:n,onSelect:()=>{d(),s(g)}})}}a();var uo=l(vo());L();var re=l(p()),Ve=()=>(0,re.jsx)("div",{style:{margin:"0 -2rem -1.5rem -2rem"},children:(0,re.jsxs)("a",{className:"border-top border-darken2 px3 py2 flex flex-none items-center justify-left",href:"https://airtable.com/shrhZS16yCXsFJDxj",target:"_blank",rel:"noopener noreferrer",children:[(0,re.jsx)(uo.Icon,{name:"megaphone",size:16}),(0,re.jsx)("div",{className:"ml1 lighten4",children:(0,re.jsx)(y,{defaultMessage:[{type:0,value:"Give feedback about the data library"}],id:"PiVy/p"})})]})});Me();a();var yo={airtableSharedView:"Airtable",atlassianJira:"Jira Cloud",atlassianJiraServer:"Jira Server",googleCalendar:"Google Calendar",organizationClaimList:"Organization Claim List",googleDrive:"Google Drive",salesforce:"Salesforce",box:"Box",emailedCsv:"Emailed CSV",microsoftOutlookCalendar:"Outlook Calendar",githubIssues:"GitHub Issues",githubPullRequests:"GitHub Pull Requests",zendesk:"Zendesk",miro:"Miro",tableauOnline:"Tableau Online",tableauServer:"Tableau Server",adobeExperienceManager:"Adobe Experience Manager",apiEndpoint:"Sync API",snowflake:"Snowflake",github:"Github Issues",workday:"Workday",dataTable:"Data Table",azureDevOps:"Azure DevOps"};pe();var O=l(p());function Bo(e,t){var o,r;return(r=(o=te[t])==null?void 0:o.getName(e))!=null?r:yo[t]}function wo(e){return Ct.default([...lt,...Be().map(t=>t.dataSourceType)].map(t=>({name:Bo(e,t),sourceType:t})),t=>t.sourceType==="airtableSharedView"?"0":t.name)}var ko=At.default((e,t)=>{F.track("application.addSyncOrImportDialog.search",{origin:e,searchQuery:t})},500);function io(e){let{onClose:t,applicationModel:o,onSelectImportSource:r,onSelectSyncSource:s,publishedDatasetData:c,startingTab:d,eligibleTabs:S,origin:C,blockHumanReadableNameByBlockId:N}=e,u=M(),f=wo(u),g=(0,ae.useMemo)(()=>new xe(f,{threshold:.2,keys:["name"]}),[f]),[n,i]=(0,ae.useState)(""),A=()=>{if(n==="")return f.map(({sourceType:_})=>_);let v=g.search(n).map(_=>_.item.sourceType);return ko("otherSourcesTab",n),v},[E,V]=(0,ae.useState)(d),J=v=>{F.track("application.addSyncOrImportDialog.tab.open",{choice:v}),V(v)};(0,ae.useEffect)(()=>{let v=document.getElementById("new-data-source-container");if(!v)return;let _=window.getComputedStyle(v).getPropertyValue("grid-template-columns").split(" ").length;v.style.gridTemplateColumns=`repeat(${_}, minmax(330px, 1fr))`},[]);let I=Re(()=>o.getBillingPlanLive(),[o]);function P(){switch(E){case"libraryTab":return B.assert(c,"Published dataset data does not exist"),(0,O.jsx)(Ge,{publishedDatasetData:c,applicationModel:o});case"otherSourcesTab":return(0,O.jsxs)(ut.Fragment,{children:[(0,O.jsx)(yt,{searchQuery:n,setSearchQuery:i,placeHolderText:u.formatMessage({defaultMessage:[{type:0,value:"Find a source"}],id:"T1iN4L"})}),(0,O.jsx)("div",{id:"new-data-source-container",className:"sync-or-import-dialog light-scrollbar",children:[...A(),dt].map((v,_)=>(0,O.jsx)(po,{sourceType:v,allowedTableSyncSourcesBySyncSourceType:Pe(o),applicationBillingPlan:I,onSelectImportSource:r,onSelectSyncSource:s,onCloseDialog:t,blockHumanReadableNameByBlockId:N},_))})]});default:throw new Q(E)}}return Oe(()=>{F.track("application.addSyncOrImportDialog.open",{origin:C}),F.track("application.addSyncOrImportDialog.tab.open",{choice:d})}),(0,O.jsx)(ut.Fragment,{children:(0,O.jsxs)(Lt,{onClose:()=>{F.track("application.addSyncOrImportDialog.close"),t()},className:(0,fo.default)("height-full px2-and-half py3 overflow-hidden",Jt.className),style:{maxHeight:"min(calc(100vh - 10rem), 641px)",maxWidth:"min(calc(100vw - 20rem), 1200px)",minWidth:"430px"},closeButtonStyle:{margin:"1.75rem 1.75rem 0 0"},children:[(0,O.jsxs)("div",{className:"flex items-center",children:[(0,O.jsx)(R,{name:"BookOpen",svgClassName:"huge truncated mr2 mb2",scale:1.8}),(0,O.jsx)("div",{className:"huge truncated mr1 mb2",style:{fontSize:"1.4rem",fontWeight:"bolder"},children:(0,O.jsx)(y,{defaultMessage:[{type:0,value:"Add data to a new table"}],id:"TohX2F"})})]}),S.length>1?(0,O.jsx)(mo,{onTabChange:J,currentTab:E,eligibleTabs:S}):(0,O.jsx)("hr",{style:{width:"auto",margin:"0.5rem -2rem 0 -2rem",border:Ue(.5)}}),(0,O.jsx)("div",{className:"flex flex-column",style:{minHeight:0,flexGrow:1},children:P()}),E==="libraryTab"&&(0,O.jsx)(Ve,{})]})})}function yt(e){return(0,O.jsx)(Ft,{"aria-label":e.placeHolderText,placeholder:e.placeHolderText,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),style:{borderBottom:Ue(1),height:"40px",width:"calc(100% - 12px)",borderRadius:"0"},wrapperProps:{className:"mt-half"}})}a();var We=l(ye());L();Xe();var k=l(p());var ft=363;function So({publishedDataset:e,datasetOwner:t,onSelect:o,isSelected:r}){return(0,k.jsx)(ne,{as:"div",onClick:()=>{o(e)},children:(0,k.jsx)(_o,{cardPreviewInfo:{name:e.name,description:e.description,ownerUserProfileInfo:t},isOwnerMemberOfEnterprise:e.isOwnerMemberOfEnterprise,isSelected:r,isVerified:e.verificationInfo.status==="verified",isInEditMode:!!e})})}function _o({cardPreviewInfo:e,isOwnerMemberOfEnterprise:t,isSelected:o,isVerified:r,isInEditMode:s}){let c=r,d={height:"149px",minWidth:ft};return(0,k.jsxs)("div",{className:(0,We.default)("p2 pointer sync-or-import-source-card colors-background-default item-center",{"colors-background-subtler border-thick border-blue":o,"border-thick border-white":!o}),style:c?q(D({},d),{borderLeftWidth:"0",borderRightWidth:"0",paddingTop:"14px"}):q(D({},d),{paddingTop:"16px"}),children:[(0,k.jsxs)("div",{className:"flex justify-between width-full",children:[(0,k.jsx)("div",{className:"flex items-center truncate",children:(0,k.jsx)("p",{className:(0,We.default)("huge strongest truncate mt-half mb1 font-family-display-updated",{"text-dark":e.name,"text-darken4":!e.name}),children:e.name?e.name:(0,k.jsx)(y,{defaultMessage:[{type:0,value:"Dataset Name"}],id:"UM4CIA"})})}),c&&(0,k.jsx)(Zt,{})]}),(0,k.jsx)(fe,{content:(0,k.jsx)("div",{style:{maxWidth:250},children:e.description}),shouldOnlyShowIfTruncated:!0,children:(0,k.jsx)("p",{className:(0,We.default)("normal truncate-block-2-lines line-height-4 font-family-display-updated",{"text-dark":e.description,"text-darken4":!e.description}),style:{minHeight:"42px"},children:e.description?e.description:(0,k.jsx)(y,{defaultMessage:[{type:0,value:"Description"}],id:"Ssg4RJ"})})}),e.ownerUserProfileInfo&&(0,k.jsx)(Bt,D({className:"pt-half mt1-and-half",userName:e.ownerUserProfileInfo.name,collaboratorId:e.ownerUserProfileInfo.id,profilePicUrl:e.ownerUserProfileInfo.profilePicUrl},s&&!t&&e.ownerUserProfileInfo.id&&{profilePicOverride:(0,k.jsx)("div",{className:"flex justify-center items-center z1",children:(0,k.jsx)(wt,{})})}))]})}Me();Rt();pe();var b=l(p()),Po=xt({display:"grid",gridGap:zt.space2,gridTemplateColumns:`repeat(auto-fill, minmax(${ft}px, 1fr))`});function Ge(e){let t=M(),[o,r]=(0,K.useState)(null),[s,c]=(0,K.useState)(""),d=Wt(s,100),S=async function(n){F.track("application.addSyncOrImportDialog.verifiedData.dataset.click"),r(n);let i=e.publishedDatasetData.userProfileInfoByUserId[n.ownerId];B.assert(i,"ownerUserProfileInfo is undefined",{userId:n.ownerId}),le(t,(0,b.jsx)(we,q(D({dataset:n,ownerUserProfileInfo:i,onClose:()=>{r(null)}},D({},e.onConfirm?{onConfirm:(A,E)=>{e.onConfirm(n,A,E)}}:{applicationModel:e.applicationModel})),{shouldShowAddDatasetButton:!0})))},C=e.publishedDatasetData.datasets,N=(0,K.useMemo)(()=>C.map(n=>{let i=e.publishedDatasetData.userProfileInfoByUserId[n.ownerId];return B.assert(i,"datasetOwner should be defined",{userId:n.ownerId}),q(D({},n),{ownerName:i.name,ownerEmail:i.email})}),[C,e.publishedDatasetData.userProfileInfoByUserId]),u=(0,K.useMemo)(()=>new xe(N,{keys:["name","description","ownerName","ownerEmail"],threshold:0,ignoreLocation:!0}).search(d.trim()).map(i=>i.item),[N,d]),f=d===""?C:u,g=(0,K.useMemo)(()=>ke(f),[f]);return C.length===0?(0,b.jsx)("div",{className:`width-full height-full flex justify-center items-center ${e.className}`,children:(0,b.jsxs)("div",{className:"center",children:[(0,b.jsx)("h3",{className:"strong mb-1",children:(0,b.jsx)(y,{defaultMessage:[{type:0,value:"No data sets added to library yet"}],id:"HxfXiA"})}),(0,b.jsx)("p",{children:(0,b.jsx)("span",{className:"text-gray",children:(0,b.jsx)(y,{defaultMessage:[{type:0,value:"Your organization's admins can add data sets to the library so others can easily find and sync data to their bases. "},{type:8,value:"link",children:[{type:0,value:"Learn More."}]}],id:"3lh0CJ",values:{link:n=>(0,b.jsx)(Je,{pageName:"verifiedDataOverview",className:"strong text-blue",children:n})}})})})]})}):(0,b.jsxs)(K.Fragment,{children:[(0,b.jsx)("div",{className:"flex mt1",style:{display:"inline"},children:(0,b.jsx)(y,{id:"WU7Kxy",defaultMessage:[{type:0,value:"Select a data set to preview the data and other details before adding it to a new table in this base. Some data sets may be marked as verified, which means that they\u2019ve been approved by an admin in your organization. "},{type:8,value:"a",children:[{type:0,value:"Learn more"}]}],values:{a:n=>(0,b.jsx)(Je,{pageName:"usingDatasets",className:"strong underline",children:n})}})}),(0,b.jsx)(yt,{searchQuery:s,setSearchQuery:c,placeHolderText:t.formatMessage({defaultMessage:[{type:0,value:"Find a data set"}],id:"L9QW3N"})}),g.length===0?(0,b.jsxs)("div",{className:"width-full height-full flex flex-column items-center justify-center",children:[(0,b.jsx)("h3",{className:"strong",children:(0,b.jsx)(y,{defaultMessage:[{type:0,value:"No data sets found"}],id:"aW65LL"})}),(0,b.jsx)("p",{children:(0,b.jsx)("span",{className:"text-gray",children:(0,b.jsx)(y,{defaultMessage:[{type:0,value:"Your search for "},{type:8,value:"b",children:[{type:1,value:"searchQuery"}]},{type:0,value:" didn't match the name or description of any data sets in the library."}],id:"6nkRYK",values:{searchQuery:s,b:n=>(0,b.jsx)("b",{children:n})}})})})]}):(0,b.jsx)("div",{className:(0,go.default)("sync-or-import-dialog mt2 light-scrollbar",Po),children:g.filter(n=>n.type!=="data_table"||Ce("dataTableSyncSource")).map(n=>{let i=e.publishedDatasetData.userProfileInfoByUserId[n.ownerId];return B.assert(i,"datasetOwner should be defined",{userId:n.ownerId}),(0,b.jsx)(So,{publishedDataset:n,datasetOwner:i,onSelect:S,isSelected:n===o},`${n.applicationId}, ${n.shareId}`)})})]})}pe();var se=l(p()),kl=({targetApplicationId:e,targetWorkspaceId:t,publishedDatasetData:o,onSuccessfulSchemaFetch:r,errorMessage:s})=>{let c=M(),d=async(S,C,N)=>{B.assert.strictEqual(S.type,"shared_view");let{shareId:u,applicationId:f}=S;try{if(f===e){Ht(c,{title:c.formatMessage({defaultMessage:[{type:0,value:"Not possible to sync data between tables in the same base"}],id:"BN7Tex"}),message:c.formatMessage({defaultMessage:[{type:0,value:"It is not possible to sync data between tables in the same base. You can access the original version of this table inside this base."}],id:"OfHgEC"}),shouldShowCancelButton:!1}),C();return}let g=B.logger.addChild({context:"upconvertTableToSyncedTable",applicationId:e}),{schema:n,externalAccountId:i,sourceInfoDisplayProperties:A}=await Qt({targetApplicationId:e,targetWorkspaceId:t,sourceApplicationId:f,shareId:u,logger:g});r({sourceExternalAccountId:i,sourceSchema:n,sourceInfoDisplayProperties:A}),N()}catch(g){B.logger.error("An error occurred wheb selecting verified data",{err:g}),C()}};return o=(0,To.useMemo)(()=>q(D({},o),{datasets:kt(o.datasets)}),[o]),(0,se.jsxs)("div",{className:"flex flex-column px2-and-half pb2-and-half pt1 overflow-hidden height-full",children:[(0,se.jsxs)("div",{className:"flex flex-column overflow-hidden height-full",children:[(0,se.jsx)(Ge,{publishedDatasetData:o,onConfirm:d}),s]}),(0,se.jsx)(Ve,{})]})};a();X();var Hl=({sourceSchema:e,targetTablePrimaryColumn:t})=>{let o=e.columnInfoByExternalFieldId[e.primaryColumnExternalFieldId];return!o||o.type!==t.type?{}:{[t.id]:e.primaryColumnExternalFieldId}},Vl=e=>D({id:e.id},e.getConfigWithColumnName()),Gl=({sourceViewColumnsById:e,targetTablePrimaryColumn:t})=>{for(let[o,r]of ve(e))if(De(t.type).has(r.type)&&Ae(r))return!0;return!1},Wl=e=>{let t={};for(let{type:o}of e){let r=t[o];r?t[o]=r+1:t[o]=1}return t};export{ft as a,_o as b,Za as c,je as d,Xo as e,et as f,wr as g,kl as h,Hl as i,Vl as j,Gl as k,Wl as l};
//# sourceMappingURL=https://airtable.com/jsSourceMap/esbuild/production/chunks/chunk-PTH23L6S.js.map