"use strict";(globalThis.webpackChunksuperset=globalThis.webpackChunksuperset||[]).push([[4593],{82607:(e,a,t)=>{t.d(a,{Z:()=>s}),t(67294);var n=t(51995),l=t(62529),o=t(11965);const s=(0,n.iK)((({textColor:e,...a})=>(0,o.tZ)(l.Z,a)))`
  & > sup {
    padding: 0 ${({theme:e})=>2*e.gridUnit}px;
    background: ${({theme:e,color:a})=>a||e.colors.primary.base};
    color: ${({theme:e,textColor:a})=>a||e.colors.grayscale.light5};
  }
`},57011:(e,a,t)=>{t.d(a,{Z:()=>i});var n=t(5872),l=t.n(n),o=(t(67294),t(70302)),s=t(11965);const i=({padded:e,...a})=>(0,s.tZ)(o.Z,l()({},a,{css:a=>({backgroundColor:a.colors.grayscale.light4,borderRadius:a.borderRadius,".ant-card-body":{padding:e?4*a.gridUnit:a.gridUnit}})}))},79789:(e,a,t)=>{t.d(a,{Z:()=>d});var n=t(67294),l=t(51995),o=t(61988),s=t(70163),i=t(58593),r=t(11965);const d=function({certifiedBy:e,details:a,size:t="l"}){const d=(0,l.Fg)();return(0,r.tZ)(i.u,{id:"certified-details-tooltip",title:(0,r.tZ)(n.Fragment,null,e&&(0,r.tZ)("div",null,(0,r.tZ)("strong",null,(0,o.t)("Certified by %s",e))),(0,r.tZ)("div",null,a))},(0,r.tZ)(s.Z.Certified,{iconColor:d.colors.primary.base,iconSize:t}))}},73995:(e,a,t)=>{t.d(a,{Z:()=>Z});var n=t(67294),l=t(51995),o=t(31069),s=t(61988),i=t(15926),r=t.n(i),d=t(4715),c=t(37921),m=t(49238),u=t(40277),b=t(14114),h=t(11965);const p=l.iK.div`
  ${({theme:e})=>`\n    .refresh {\n      display: flex;\n      align-items: center;\n      width: 30px;\n      margin-left: ${e.gridUnit}px;\n      margin-top: ${5*e.gridUnit}px;\n    }\n\n    .section {\n      display: flex;\n      flex-direction: row;\n      align-items: center;\n    }\n\n    .select {\n      width: calc(100% - 30px - ${e.gridUnit}px);\n      flex: 1;\n    }\n\n    & > div {\n      margin-bottom: ${4*e.gridUnit}px;\n    }\n  `}
`,g=l.iK.div`
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-left: ${({theme:e})=>e.gridUnit-2}px;

  .backend {
    overflow: visible;
  }

  .name {
    overflow: hidden;
    text-overflow: ellipsis;
  }
`,f=({backend:e,databaseName:a})=>(0,h.tZ)(g,null,(0,h.tZ)(c.Z,{className:"backend"},e),(0,h.tZ)("span",{className:"name",title:a},a));function Z({db:e,formMode:a=!1,getDbList:t,handleError:l,isDatabaseSelectEnabled:i=!0,onDbChange:c,onSchemaChange:g,onSchemasLoad:Z,readOnly:v=!1,schema:y,sqlLabMode:S=!1}){const[x,w]=(0,n.useState)(!1),[C,_]=(0,n.useState)([]),[k,$]=(0,n.useState)(e?{label:(0,h.tZ)(f,{backend:e.backend,databaseName:e.database_name}),value:e.id,...e}:void 0),[L,N]=(0,n.useState)(y?{label:y,value:y}:void 0),[U,E]=(0,n.useState)(0),{addSuccessToast:z}=(0,b.e1)(),D=(0,n.useMemo)((()=>async(e,n,i)=>{const d=`/api/v1/database/?q=${r().encode({order_columns:"database_name",order_direction:"asc",page:n,page_size:i,...a||!S?{filters:[{col:"database_name",opr:"ct",value:e}]}:{filters:[{col:"database_name",opr:"ct",value:e},{col:"expose_in_sqllab",opr:"eq",value:!0}]}})}`;return o.Z.get({endpoint:d}).then((({json:e})=>{const{result:a}=e;t&&t(a),0===a.length&&l((0,s.t)("It seems you don't have access to any database"));const n=a.map((e=>({label:(0,h.tZ)(f,{backend:e.backend,databaseName:e.database_name}),value:e.id,id:e.id,database_name:e.database_name,backend:e.backend,allow_multi_schema_metadata_fetch:e.allow_multi_schema_metadata_fetch})));return{data:n,totalCount:n.length}}))}),[a,t,l,S]);function T(e,a){return(0,h.tZ)("div",{className:"section"},(0,h.tZ)("span",{className:"select"},e),(0,h.tZ)("span",{className:"refresh"},a))}return(0,n.useEffect)((()=>{if(k){w(!0);const e=r().encode({force:U>0}),a=`/api/v1/database/${k.value}/schemas/?q=${e}`;o.Z.get({endpoint:a}).then((({json:e})=>{const a=e.result.map((e=>({value:e,label:e,title:e})));Z&&Z(a),_(a),w(!1),U>0&&z("List refreshed")})).catch((()=>{w(!1),l((0,s.t)("There was an error loading the schemas"))}))}}),[k,Z,U]),(0,h.tZ)(p,null,T((0,h.tZ)(d.Ph,{ariaLabel:(0,s.t)("Select database or type database name"),optionFilterProps:["database_name","value"],header:(0,h.tZ)(m.lX,null,(0,s.t)("Database")),lazyLoading:!1,onChange:function(e,a){$(a),N(void 0),c&&c(a),g&&g(void 0)},value:k,placeholder:(0,s.t)("Select database or type database name"),disabled:!i||v,options:D}),null),function(){const e=!a&&!v&&(0,h.tZ)(u.Z,{onClick:()=>E(U+1),tooltipContent:(0,s.t)("Force refresh schema list")});return T((0,h.tZ)(d.Ph,{ariaLabel:(0,s.t)("Select schema or type schema name"),disabled:v,header:(0,h.tZ)(m.lX,null,(0,s.t)("Schema")),labelInValue:!0,lazyLoading:!1,loading:x,name:"select-schema",placeholder:(0,s.t)("Select schema or type schema name"),onChange:e=>function(e){N(e),g&&g(e.value)}(e),options:C,showSearch:!0,value:L}),e)}())}},40277:(e,a,t)=>{t.d(a,{Z:()=>i});var n=t(67294),l=t(58593),o=t(70163),s=t(11965);const i=({onClick:e,tooltipContent:a})=>{const t=(0,n.forwardRef)(((e,a)=>(0,s.tZ)(o.Z.Refresh,e)));return(0,s.tZ)(l.u,{title:a},(0,s.tZ)(t,{role:"button",onClick:e,css:e=>({cursor:"pointer",color:e.colors.grayscale.base,"&:hover":{color:e.colors.primary.base}})}))}},17982:(e,a,t)=>{t.d(a,{Z:()=>v});var n=t(67294),l=t(51995),o=t(31069),s=t(61988),i=t(4715),r=t(49238),d=t(70163),c=t(73995),m=t(40277),u=t(79789),b=t(86057),h=t(14114),p=t(11965);const g=l.iK.div`
  ${({theme:e})=>`\n    .refresh {\n      display: flex;\n      align-items: center;\n      width: 30px;\n      margin-left: ${e.gridUnit}px;\n      margin-top: ${5*e.gridUnit}px;\n    }\n\n    .section {\n      display: flex;\n      flex-direction: row;\n      align-items: center;\n    }\n\n    .divider {\n      border-bottom: 1px solid ${e.colors.secondary.light5};\n      margin: 15px 0;\n    }\n\n    .table-length {\n      color: ${e.colors.grayscale.light1};\n    }\n\n    .select {\n      flex: 1;\n    }\n  `}
`,f=l.iK.span`
  align-items: center;
  display: flex;
  white-space: nowrap;

  svg,
  small {
    margin-right: ${({theme:e})=>e.gridUnit}px;
  }
`,Z=({table:e})=>{const{label:a,type:t,extra:n}=e;return(0,p.tZ)(f,{title:a},"view"===t?(0,p.tZ)(d.Z.Eye,{iconSize:"m"}):(0,p.tZ)(d.Z.Table,{iconSize:"m"}),(null==n?void 0:n.certification)&&(0,p.tZ)(u.Z,{certifiedBy:n.certification.certified_by,details:n.certification.details,size:"l"}),(null==n?void 0:n.warning_markdown)&&(0,p.tZ)(b.Z,{warningMarkdown:n.warning_markdown,size:"l"}),a)},v=({database:e,formMode:a=!1,getDbList:t,handleError:l,isDatabaseSelectEnabled:d=!0,onDbChange:u,onSchemaChange:b,onSchemasLoad:f,onTableChange:v,onTablesLoad:y,readOnly:S=!1,schema:x,sqlLabMode:w=!0,tableName:C})=>{const[_,k]=(0,n.useState)(e),[$,L]=(0,n.useState)(x),[N,U]=(0,n.useState)(),[E,z]=(0,n.useState)(0),[D,T]=(0,n.useState)(0),[M,q]=(0,n.useState)(!1),[R,F]=(0,n.useState)([]),{addSuccessToast:I}=(0,h.e1)();(0,n.useEffect)((()=>{void 0===e&&(k(void 0),L(void 0),U(void 0))}),[e]),(0,n.useEffect)((()=>{if(_&&$){q(!0);const e=encodeURIComponent($),a=E!==D,t=encodeURI(`/superset/tables/${_.id}/${e}/undefined/${a}/`);D!==E&&T(E),o.Z.get({endpoint:t}).then((({json:e})=>{const t=[];let n;e.options.forEach((e=>{const a={value:e.value,label:(0,p.tZ)(Z,{table:e}),text:e.label};t.push(a),e.label===C&&(n=a)})),null==y||y(e.options),F(t),U(n),q(!1),a&&I("List updated")})).catch((()=>{q(!1),l((0,s.t)("There was an error loading the tables"))}))}}),[_,$,y,E]);const K=e=>{U(e),v&&$&&v(null==e?void 0:e.value,$)},O=(0,n.useMemo)((()=>(e,a)=>{const t=e.trim().toLowerCase(),{text:n}=a;return n.toLowerCase().includes(t)}),[]);return(0,p.tZ)(g,null,(0,p.tZ)(c.Z,{key:null==_?void 0:_.id,db:_,formMode:a,getDbList:t,handleError:l,onDbChange:S?void 0:e=>{k(e),u&&u(e)},onSchemaChange:S?void 0:e=>{L(e),b&&b(e),K(void 0)},onSchemasLoad:f,schema:$,sqlLabMode:w,isDatabaseSelectEnabled:d&&!S,readOnly:S}),w&&!a&&(0,p.tZ)("div",{className:"divider"}),function(){const t=$&&!a&&S||!$&&!(null!=e&&e.allow_multi_schema_metadata_fetch),n=w?(0,p.tZ)(r.lX,null,(0,s.t)("See table schema")):(0,p.tZ)(r.lX,null,(0,s.t)("Table"));return l=(0,p.tZ)(i.Ph,{ariaLabel:(0,s.t)("Select table or type table name"),disabled:t,filterOption:O,header:n,labelInValue:!0,lazyLoading:!1,loading:M,name:"select-table",onChange:e=>K(e),options:R,placeholder:(0,s.t)("Select table or type table name"),showSearch:!0,value:N}),o=!a&&!S&&(0,p.tZ)(m.Z,{onClick:()=>z(E+1),tooltipContent:(0,s.t)("Force refresh table list")}),(0,p.tZ)("div",{className:"section"},(0,p.tZ)("span",{className:"select"},l),(0,p.tZ)("span",{className:"refresh"},o));var l,o}())}}}]);