UNPKG

@nocobase/plugin-file-manager

Version:

Provides files storage services with files collection template and attachment field.

10 lines (9 loc) 113 kB
/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-manager",["react-i18next","@emotion/css","@formily/react","@ant-design/icons","@nocobase/flow-engine","ahooks","@nocobase/client-v2","@formily/shared","react","antd","@nocobase/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-file-manager"]=t(require("react-i18next"),require("@emotion/css"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("lodash")):e["@nocobase/plugin-file-manager"]=t(e["react-i18next"],e["@emotion/css"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.ahooks,e["@nocobase/client-v2"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,l,c,u,s,p){return function(){var f={484:function(e,t,n){var r=n(986),o=/[\/\+\.]/;e.exports=function(e,t){function n(t){var n=r(t,e,o);return n&&n.length>=2}return t?n(t.split(";")[0]):n}},986:function(e){"use strict";function t(e,t){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=t,this.parts=e.split(t)}t.prototype.match=function(e){var t,n,r=!0,o=this.parts,i=o.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(t=0,n=(e||"").split(this.separator);r&&t<i;t++)if("*"===o[t])continue;else r=t<n.length&&o[t]===n[t];r=r&&n}else r=!1;else if("function"==typeof e.splice)for(r=[],t=e.length;t--;)this.match(e[t])&&(r[r.length]=e[t]);else if("object"==typeof e)for(var a in r={},e)this.match(a)&&(r[a]=e[a]);return r},e.exports=function(e,n,r){var o=new t(e,r||/[\/\.]/);return void 0!==n?o.match(n):o}},375:function(e){"use strict";e.exports=r},477:function(e){"use strict";e.exports=t},230:function(e){"use strict";e.exports=n},166:function(e){"use strict";e.exports=l},342:function(e){"use strict";e.exports=s},485:function(e){"use strict";e.exports=a},313:function(e){"use strict";e.exports=o},625:function(e){"use strict";e.exports=i},59:function(e){"use strict";e.exports=u},773:function(e){"use strict";e.exports=p},155:function(e){"use strict";e.exports=c},953:function(t){"use strict";t.exports=e}},d={};function m(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return f[e](n,n.exports,m),n.exports}m.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return m.d(t,{a:t}),t},m.d=function(e,t){for(var n in t)m.o(t,n)&&!m.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},m.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),m.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},m.g.importScripts&&(y=m.g.location+"");var y,b=m.g.document;if(!y&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(y=b.currentScript.src),!y)){var g=b.getElementsByTagName("script");if(g.length)for(var h=g.length-1;h>-1&&(!y||!/^http(s?):/.test(y));)y=g[h--].src}if(!y)throw Error("Automatic publicPath is not supported in this browser");m.p=y.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-file-manager/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-file-manager/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",l=a.indexOf(i);e=l>=0?a.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-manager/dist/client/"}m.p=e}(),!function(){"use strict";m.r(v),m.d(v,{UploadFieldModel:function(){return tI},default:function(){return na},PluginFileManagerClient:function(){return ni},filePreviewTypes:function(){return eP},wrapWithModalPreviewer:function(){return eW},CardUpload:function(){return tF}});var e,t,n,r={};m.r(r),m.d(r,{useAttachmentFieldProps:function(){return h},useFileCollectionStorageRules:function(){return w},useStorageRules:function(){return g},useUploadFiles:function(){return y}});var o=m(155),i=m.n(o),a=m(342);function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function c(e,t){if(!t||"main"===t)return e;var n=e.includes("?")?"&":"?";return"".concat(e).concat(n,"uploadDataSourceKey=").concat(encodeURIComponent(t))}function u(){var e,t,n,r,i,l,u,s,p=(0,a.useCollectionField)(),f=(0,a.useCollectionManager)().getCollection(null==p?void 0:p.target),d=(0,a.useCollection)(),m=(0,a.usePlugin)(na),y=(t=null!=(e=(null==p?void 0:p.storage)||(null==d?void 0:d.getOption("storage"))||(null==f?void 0:f.getOption("storage")))?e:"",n=(0,a.useDataSourceKey)(),r=c("storages:getBasicInfo/".concat(t),n),l=(i=(0,a.useRequest)({url:r},{manual:!0,refreshDeps:[t,n],cacheKey:"".concat(n||"main",":").concat(r)})).loading,u=i.data,s=i.run,(0,o.useEffect)(function(){s()},[s]),!l&&(null==u?void 0:u.data)||null),b=m.getStorageType(null==y?void 0:y.type);return{storage:y,storageType:b}}function s(e){var t,n,r=(0,a.useDataSourceKey)(),o=u(),i=o.storage,s=o.storageType,p=null==s?void 0:s.useUploadProps,f=(null==p?void 0:p(l({storage:i,rules:i.rules},e)))||{},d=l({},f.headers);return t=l({action:c(e.action,r),rules:null==i?void 0:i.rules},f),n=n={headers:d},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||d(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}}var y=function(){var e=(0,a.useDataBlockRequestGetter)().getDataBlockRequest,t=((0,a.useDataBlockProps)()||{}).association,n=(0,a.useActionContext)().setVisible,r=(0,a.useCollection)(),i=(0,a.useSourceId)(),l=(0,o.useMemo)(function(){var e="".concat(r.name,":create");if(t){var n,o=function(e){if(Array.isArray(e))return e}(n=t.split("."))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||d(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=o[0],l=o[1];e="".concat(a,"/").concat(i,"/").concat(l,":create")}return e},[r.name,t,i]),c=((0,o.useContext)(a.RecordPickerContext)||{}).setSelectedRows,u={},p=0,m={action:l,onChange:function(t){t.forEach(function(n){if("uploading"!==n.status||u[n.uid]||(p++,u[n.uid]=!0),"uploading"!==n.status&&u[n.uid]&&(delete u[n.uid],0==--p)){var r,o;null==(o=e())||null==(r=o.refresh)||r.call(o),null==c||c(function(e){return f(e).concat(f(t.filter(function(e){return"done"===e.status}).map(function(e){return e.response.data})))})}}),t.every(function(e){return"done"===e.status})&&n(!1)}},y=s(m);return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},m,y)},b=m(230);function g(e){var t,n=null!=e?e:"",r=(0,a.useDataSourceKey)(),i=(0,b.useField)(),l=(0,a.useRequest)({url:function(e,t){if(!t||"main"===t)return e;var n=e.includes("?")?"&":"?";return"".concat(e).concat(n,"uploadDataSourceKey=").concat(encodeURIComponent(t))}("storages:getBasicInfo/".concat(n),r)},{manual:!0,refreshDeps:[n,r],cacheKey:"".concat(r||"main",":storages:getBasicInfo/").concat(n)}),c=l.loading,u=l.data,s=l.run;return(0,o.useEffect)(function(){"editable"===i.pattern&&s()},[i.pattern,s]),!c&&(null==u||null==(t=u.data)?void 0:t.rules)||null}function h(){var e=(0,a.useCollectionField)(),t="".concat(null==e?void 0:e.target,":create").concat((null==e?void 0:e.storage)?"?attachmentField=".concat(e.collectionName,".").concat(e.name):""),n=s({action:t});return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({action:t},n)}function w(){var e=(0,a.useCollectionField)(),t=(0,a.useCollectionManager)().getCollection(null==e?void 0:e.target);return g(null==t?void 0:t.getOption("storage"))}var x=function(e){var t,n,r={type:"void","x-action":"create",title:"{{t('Upload')}}","x-designer":"Action.Designer","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",icon:"UploadOutlined"},properties:{drawer:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Action.Container",properties:{upload:{type:"void",title:'{{ t("Upload files") }}',"x-component":"Upload.DraggerV2","x-use-component-props":"useUploadFiles","x-component-props":{height:"50vh",multiple:!0,listType:"picture"}}}}}};return i().createElement(a.ActionInitializerItem,(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),n=n={schema:r},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))},O="file-manager",S={dumpRules:{group:"user"},migrationRules:["schema-only","overwrite"],asStrategyResource:!0,shared:!0,name:"attachments",dataCategory:"business",createdBy:!0,updatedBy:!0,template:"file",filterTargetKey:"id",fields:[{comment:"用户文件名(不含扩展名)",type:"string",name:"title"},{comment:"系统文件名(含扩展名)",type:"string",name:"filename"},{comment:"扩展名(含“.”)",type:"string",name:"extname"},{comment:"文件体积(字节)",type:"integer",name:"size"},{type:"string",name:"mimetype"},{type:"belongsTo",name:"storage",target:"storages",foreignKey:"storageId",deletable:!1,interface:"m2o",uiSchema:{type:"object",title:"{{t('Storage', { ns: '".concat(O,"' })}}"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"title"}},"x-read-pretty":!0}},{comment:"相对路径(含“/”前缀)",type:"text",name:"path"},{comment:"其他文件信息(如图片的宽高)",type:"jsonb",name:"meta",defaultValue:{}},{comment:"网络访问地址",type:"text",name:"url"}]},j={dumpRules:"required",migrationRules:["overwrite","schema-only"],name:"storages",dataCategory:"system",shared:!0,fields:[{name:"id",type:"snowflakeId",primaryKey:!0,allowNull:!1},{title:"存储引擎名称",comment:"存储引擎名称",type:"string",name:"title",translation:!0,trim:!0},{title:"英文标识",type:"uid",name:"name",unique:!0,trim:!0},{comment:"类型标识,如 local/ali-oss 等",type:"string",name:"type"},{comment:"配置项",type:"jsonb",name:"options",defaultValue:{}},{comment:"文件规则",type:"jsonb",name:"rules",defaultValue:{}},{comment:"存储相对路径模板",type:"text",name:"path",defaultValue:"",trim:!0},{comment:"访问地址前缀",type:"string",name:"baseUrl",defaultValue:"",trim:!0},{comment:"重命名模式",type:"string",name:"renameMode",defaultValue:"appendRandomID"},{comment:"默认引擎",type:"radio",name:"default",defaultValue:!1},{type:"boolean",name:"paranoid",defaultValue:!1},{type:"json",name:"settings",defaultValue:{}}]},P=function(e){return i().createElement(a.ExtendCollectionsProvider,{collections:[S,j]},i().createElement(a.SchemaComponentOptions,{scope:r,components:{UploadActionInitializer:x}},e.children))},E=m(59),C=[{value:1,label:"Byte"},{value:1024,label:"KB"},{value:1048576,label:"MB"},{value:0x40000000,label:"GB"}];function k(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1048576,n=e||t,r=C.length-1;r>=0;r--){var o=C[r];if(n%o.value==0)return o}return C[0]}function F(e,t,n){return Math.min(Math.max(t,e),n)}function I(e){var t,n=e.value,r=e.defaultUnit,a=void 0===r?1048576:r,l=e.min,c=void 0===l?1:l,u=e.max,s=void 0===u?1/0:u,p=e.step,f=e.onChange,d=null!=(t=e.defaultValue)?t:0x1400000,m=k(d,a),y=d/m.value,b=k(null!=n?n:d,a),g=null==n?n:n/b.value,h=(0,o.useCallback)(function(e){null==f||f(F(null==e?e:e*b.value,c,s))},[b.value]),v=(0,o.useCallback)(function(e){null==f||f(F(g*e,c,s))},[g]);return i().createElement(E.Space.Compact,null,i().createElement(E.InputNumber,{value:g,onChange:h,defaultValue:"".concat(y),step:void 0===p?1:p}),i().createElement(E.Select,{options:C,value:b.value,onChange:v,className:"auto-width"}))}var A=m(375),T=m(166),R=m(773),D=m.n(R),_=m(953),M={name:"storages",fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Storage name", { ns: "'.concat(O,'" })}}'),descriptions:'{{t("Will be used for API", { ns: "'.concat(O,'" })}}'),type:"string","x-component":"Input"}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Storage type", { ns: "'.concat(O,'" })}}'),type:"string","x-component":"Select",required:!0,enum:"{{ storageTypeOptions }}"}},{type:"string",name:"baseUrl",interface:"input",uiSchema:{title:'{{t("Base URL", { ns: "'.concat(O,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope",required:!0}},{type:"string",name:"path",interface:"input",uiSchema:{title:'{{t("Path", { ns: "'.concat(O,'" })}}'),type:"string","x-component":"TextAreaWithGlobalScope"}},{type:"boolean",name:"default",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}},{type:"boolean",name:"paranoid",interface:"boolean",uiSchema:{type:"boolean","x-component":"Checkbox"}}]},U={type:"object",properties:(e={},t=(0,T.uid)(),n={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:M,resourceName:"storages",request:{resource:"storages",action:"list",params:{pageSize:50,sort:["id"],appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:M},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateStorage","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Default storage", { ns: "'.concat(O,'" })}}'),properties:{default:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditStorage","x-component-props":{type:"primary"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{cm.useDestroyAction}}"}}}}}}}}}},t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e)},B={title:{"x-component":"CollectionField","x-decorator":"FormItem"},name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":"{{ !createOnly }}",required:!0,default:'{{ useNewId("s_") }}',description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with a letter.")}}'},baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Base URL for file access, could be your CDN base URL. For example: "https://cdn.nocobase.com".\', { ns: "'.concat(O,'" })}}')},path:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t(\'Relative path the file will be saved to. Left blank as root path. The leading and trailing slashes "/" will be ignored. For example: "user/avatar".\', { ns: "'.concat(O,'" })}}')},rules:{type:"object","x-component":"fieldset",properties:{size:{type:"number",title:'{{t("File size limit", { ns: "'.concat(O,'" })}}'),description:'{{t("Minimum from 1 byte.", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"FileSizeField",required:!0,default:0x1400000},mimetype:{type:"string",title:'{{t("File type allowed (in MIME type format)", { ns: "'.concat(O,'" })}}'),description:'{{t(\'Multi-types separated with comma, for example: "image/*", "image/png", "image/*, application/pdf" etc.\', { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"*"}}}},default:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Default storage", { ns: "'.concat(O,'" })}}')},paranoid:{"x-component":"CollectionField","x-decorator":"FormItem","x-content":'{{t("Keep file in storage when destroy the file record", { ns: "'.concat(O,'" })}}'),description:'{{t("Files are only removed when their corresponding records in the file collection are deleted. If a record from another collection includes an associating field referencing the file collection, the file will not be deleted unless cascade deletion is enabled for that association.", { ns: "'.concat(O,'" })}}')},renameMode:{title:'{{t("Renaming", { ns: "'.concat(O,'" })}}'),description:'{{t("Renaming strategy to avoid filename conflicts when uploading files.", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Append random ID", { ns: "'.concat(O,'" })}}'),value:"appendRandomID"},{label:'{{t("Random string", { ns: "'.concat(O,'" })}}'),value:"random"},{label:'{{t("Keep original filename (will be overwrite if filename is existed)", { ns: "'.concat(O,'" })}}'),value:"none"}],default:"appendRandomID"},settings:{type:"object",title:'{{t("Advanced Settings", { ns: "'.concat(O,'" })}}'),"x-component":"fieldset",properties:{requestOptions:{type:"object",title:'{{t("Request options", { ns: "'.concat(O,'" })}}'),description:'{{t("Additional options for HTTP requests when fetching files from remote storage on server side, such as headers.", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"Input.JSON","x-component-props":{autoSize:{minRows:5}}}}}},q={title:'{{t("Aliyun OSS", { ns: "'.concat(O,'" })}}'),name:"ali-oss",fieldset:{title:B.title,name:B.name,baseUrl:B.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",description:'{{t(\'Aliyun OSS region part of the bucket. For example: "oss-cn-beijing".\', { ns: "'.concat(O,'" })}}'),required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeySecret:{title:'{{t("AccessKey Secret", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},timeout:{title:'{{t("Timeout", { ns: "'.concat(O,'" })}}'),description:"{{t('Upload timeout for a single file in milliseconds. Default is 600000.', { ns: \"".concat(O,'" })}}'),type:"number","x-decorator":"FormItem","x-component":"InputNumber",default:6e5},thumbnailRule:{title:'{{t("File pre-process parameters", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90"},description:'{{ renderThumbnailRuleDesc("ali-oss") }}'}}},path:B.path,renameMode:B.renameMode,rules:B.rules,default:B.default,paranoid:B.paranoid,settings:B.settings},thumbnailRuleLink:"https://help.aliyun.com/zh/oss/user-guide/resize-images-4"},z={local:{title:'{{t("Local storage", { ns: "'.concat(O,'" })}}'),name:"local",fieldset:{title:B.title,name:B.name,baseUrl:{"x-component":"CollectionField","x-decorator":"FormItem","x-display":"hidden",default:"/storage/uploads"},options:{type:"object","x-component":"div",properties:{documentRoot:{title:'{{t("Destination", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"Input","x-display":"hidden",default:"storage/uploads"}}},path:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{addonBefore:"storage/uploads/"}},renameMode:B.renameMode,rules:B.rules,default:B.default,paranoid:B.paranoid}},"ali-oss":q,s3:{title:'{{t("Amazon S3", { ns: "'.concat(O,'" })}}'),name:"s3",fieldset:{title:B.title,name:B.name,baseUrl:B.baseUrl,options:{type:"object","x-component":"fieldset",properties:{region:{title:'{{t("Region", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},accessKeyId:{title:'{{t("AccessKey ID", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},secretAccessKey:{title:'{{t("AccessKey Secret", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},bucket:{title:'{{t("Bucket", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},endpoint:{title:'{{t("Endpoint", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope"}}},path:B.path,renameMode:B.renameMode,rules:B.rules,default:B.default,paranoid:B.paranoid}},"tx-cos":{title:'{{t("Tencent COS", { ns: "'.concat(O,'" })}}'),name:"tx-cos",fieldset:{title:B.title,name:B.name,baseUrl:B.baseUrl,options:{type:"object","x-component":"fieldset",properties:{Region:{title:'{{t("Region", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretId:{title:'{{t("SecretId", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},SecretKey:{title:'{{t("SecretKey", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{password:!0},required:!0},Bucket:{title:'{{t("Bucket", { ns: "'.concat(O,'" })}}'),type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope",required:!0},thumbnailRule:{title:"Thumbnail rule",type:"string","x-decorator":"FormItem","x-component":"TextAreaWithGlobalScope","x-component-props":{placeholder:"?imageMogr2/thumbnail/!50p"},description:'{{ renderThumbnailRuleDesc("tx-cos") }}'}}},path:B.path,renameMode:B.renameMode,rules:B.rules,default:B.default,paranoid:B.paranoid},thumbnailRuleLink:"https://cloud.tencent.com/document/product/436/42214"}};function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){N(e,t,n[t])})}return e}function G(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function V(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||$(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function W(e){return function(e){if(Array.isArray(e))return L(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||$(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){if(e){if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return L(e,t)}}var Y=function(){var e=V((0,o.useState)({}),2),t=e[0],n=e[1],r=(0,a.usePlugin)(na),l=(0,a.useCompile)(),c=V((0,o.useState)(!1),2),u=c[0],s=c[1],p=(0,_.useTranslation)().t;return i().createElement("div",null,i().createElement(a.ActionContext.Provider,{value:{visible:u,setVisible:s}},i().createElement(E.Dropdown,{menu:{onClick:function(e){var t=r.storageTypes.get(e.key);s(!0),n({type:"object",properties:N({},(0,T.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:t.name}},title:l("{{t('Add new')}}")+" - "+l(t.title),properties:G(K({},D().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}})})})},items:W(r.storageTypes.values()).map(function(e){return{key:e.name,label:l(e.title)}})}},i().createElement(E.Button,{type:"primary",icon:i().createElement(A.PlusOutlined,null)},p("Add new")," ",i().createElement(A.DownOutlined,null))),i().createElement(a.SchemaComponent,{scope:{createOnly:!0},schema:t})))},Z=function(){var e=(0,a.useRecord)(),t=V((0,o.useState)({}),2),n=t[0],r=t[1],l=(0,a.usePlugin)(na),c=(0,a.useCompile)(),u=V((0,o.useState)(!1),2),s=u[0],p=u[1],f=(0,_.useTranslation)().t,d=V(E.message.useMessage(),2),m=d[0],y=d[1],b=(0,o.useCallback)(function(){var t=l.storageTypes.get(e.type);t?(p(!0),t.fieldset.default&&(t.fieldset.default["x-reactions"]=function(e){e.initialValue?e.disabled=!0:e.disabled=!1}),r({type:"object",properties:N({},(0,T.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:K({},e)},title:c("{{t('Edit')}}")+" - "+c(t.title),properties:G(K({},D().cloneDeep(t.fieldset)),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}})})})):m.error(f("Storage type {{type}} is not registered, please check if related plugin is enabled.",{ns:O,type:e.type}))},[c,l.storageTypes,e]);return i().createElement("div",null,y,i().createElement(a.ActionContext.Provider,{value:{visible:s,setVisible:p}},i().createElement("a",{onClick:b},f("Edit")),i().createElement(a.SchemaComponent,{scope:{createOnly:!1},schema:n})))};function H(e){var t=z[e];return(null==t?void 0:t.thumbnailRule)?i().createElement("div",null,i().createElement("a",{target:"_blank",href:t.thumbnailRuleLink,rel:"noreferrer"},a.i18n.t("See more"))):null}var X=function(){var e=(0,a.useCompile)(),t=W((0,a.usePlugin)(na).storageTypes.values()).map(function(t){return{value:t.name,label:e(t.title)}});return i().createElement(E.Card,{bordered:!1},i().createElement(a.SchemaComponent,{components:{CreateStorage:Y,EditStorage:Z},scope:{useNewId:function(e){return"".concat(e).concat((0,T.uid)())},storageTypeOptions:t,renderThumbnailRuleDesc:H},schema:U}))};function Q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function J(e){return(J=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ee(e,t){return(ee=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function et(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(et=function(){return!!e})()}var en=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t,r,o,i;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return t=n,r=arguments,t=J(t),Q(e=function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,et()?Reflect.construct(t,r||[],J(this).constructor):t.apply(this,r)),"name","attachment"),Q(e,"type","object"),Q(e,"group","media"),Q(e,"title",'{{t("Attachment", { ns: "'.concat(O,'" })}}')),Q(e,"isAssociation",!0),Q(e,"default",{type:"belongsToMany",target:"attachments",uiSchema:{type:"array","x-component":"Upload.Attachment","x-use-component-props":"useAttachmentFieldProps"}}),Q(e,"availableTypes",["belongsToMany"]),Q(e,"properties",(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){Q(e,t,n[t])})}return e}({},a.interfacesProperties.defaultProps),i=i={"uiSchema.x-component-props.accept":{type:"string",title:'{{t("MIME type", { ns: "'.concat(O,'" })}}'),"x-component":"Input","x-component-props":{placeholder:"image/*"},"x-decorator":"FormItem",description:"Example: image/png"},"uiSchema.x-component-props.multiple":{type:"boolean","x-content":"{{t('Allow uploading multiple files', { ns: \"".concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},storage:{type:"string",title:'{{t("Storage", { ns: "'.concat(O,'" })}}'),description:"{{t('Default storage will be used when not selected', { ns: \"".concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{service:{resource:"storages",params:{}},manual:!1,fieldNames:{label:"title",value:"name"}}}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))}),o)),Q(e,"filterable",{children:[{name:"id",value:"id",title:'{{t("Exists")}}',label:'{{t("Exists")}}',operators:[{label:'{{t("exists")}}',value:"$exists",noValue:!0},{label:'{{t("not exists")}}',value:"$notExists",noValue:!0}],schema:{title:'{{t("Exists")}}',type:"string","x-component":"Input"}},{name:"filename",value:"filename",title:'{{t("Filename", { ns: "'.concat(O,'" })}}'),label:'{{t("Filename", { ns: "'.concat(O,'" })}}'),operators:a.interfacesProperties.operators.string,schema:{title:'{{t("Filename", { ns: "'.concat(O,'" })}}'),type:"string","x-component":"Input"}}]}),e}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&ee(n,e),t=[{key:"schemaInitialize",value:function(e,t){var n=t.block;t.field,e["x-component-props"]||(e["x-component-props"]={}),["Table","Kanban"].includes(n)&&(e["x-component-props"].size="small"),e["x-use-component-props"]="useAttachmentFieldProps"}},{key:"initialize",value:function(e){e.through||(e.through="t_".concat((0,T.uid)())),e.foreignKey||(e.foreignKey="f_".concat((0,T.uid)())),e.otherKey||(e.otherKey="f_".concat((0,T.uid)())),e.sourceKey||(e.sourceKey="id"),e.targetKey||(e.targetKey="id")}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(a.CollectionFieldInterface),er=m(477),eo=m(485),ei=m(313),ea=m(484),el=m.n(ea);function ec(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eu(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function es(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eu(i,r,o,a,l,"next",e)}function l(e){eu(i,r,o,a,l,"throw",e)}a(void 0)})}}function ep(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function ef(e,t,n){return(ef=ex()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&eg(o,n.prototype),o}).apply(null,arguments)}function ed(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function em(e){return(em=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ey(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ed(e,t,n[t])})}return e}function eb(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eg(e,t){return(eg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eh(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ec(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ec(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ev(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function ew(e){var t="function"==typeof Map?new Map:void 0;return(ew=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return ef(e,arguments,em(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),eg(n,e)})(e)}function ex(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ex=function(){return!!e})()}function eO(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eS(){var e,t,n=(e=["\n position: relative;\n width: 100%;\n background: #fff;\n overflow: hidden;\n --total-scale-factor: calc("," * var(--pdf-responsive-scale, 1));\n --scale-round-x: 1px;\n --scale-round-y: 1px;\n\n canvas {\n position: absolute;\n inset: 0;\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .textLayer {\n position: absolute;\n inset: 0;\n overflow: hidden;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n transform-origin: 0 0;\n z-index: 1;\n --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size, 1));\n --min-font-size-inv: calc(1 / var(--min-font-size, 1));\n }\n\n .textLayer :is(span, br) {\n position: absolute;\n color: transparent;\n white-space: pre;\n cursor: text;\n transform-origin: 0% 0%;\n }\n\n .textLayer > :not(.markedContent),\n .textLayer .markedContent span:not(.markedContent) {\n z-index: 1;\n --font-height: 0;\n --scale-x: 1;\n --rotate: 0deg;\n font-size: calc(var(--text-scale-factor) * var(--font-height));\n transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));\n }\n\n .textLayer .markedContent {\n display: contents;\n }\n\n .textLayer span[role='img'] {\n user-select: none;\n cursor: default;\n }\n\n .textLayer ::selection {\n background: rgba(0, 0, 255, 0.25);\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eS=function(){return n},n}var ej="u">typeof window&&window.__nocobase_public_path__||"/",eP=new(function(){var e;function t(){ep(this,t),ed(this,"types",[])}return e=[{key:"add",value:function(e){this.types.unshift(e)}},{key:"getTypeByFile",value:function(e){var t=eE(e);return this.types.find(function(e){return e.match(t)})}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}());function eE(e){return e&&"string"==typeof e?{url:e}:e}function eC(e){return e?"string"==typeof e?e:e.preview||e.url||"":""}function ek(e){return e?"string"==typeof e?e:e.url||e.preview||"":""}var eF={pdf:"/file-placeholder/pdf-200-200.png",mp4:"/file-placeholder/video-200-200.png",mov:"/file-placeholder/video-200-200.png",avi:"/file-placeholder/video-200-200.png",wmv:"/file-placeholder/video-200-200.png",flv:"/file-placeholder/video-200-200.png",mkv:"/file-placeholder/video-200-200.png",mp3:"/file-placeholder/audio-200-200.png",wav:"/file-placeholder/audio-200-200.png",aac:"/file-placeholder/audio-200-200.png",ogg:"/file-placeholder/audio-200-200.png",doc:"/file-placeholder/docx-200-200.png",docx:"/file-placeholder/docx-200-200.png",odt:"/file-placeholder/docx-200-200.png",xls:"/file-placeholder/xlsx-200-200.png",xlsx:"/file-placeholder/xlsx-200-200.png",csv:"/file-placeholder/xlsx-200-200.png",ppt:"/file-placeholder/pptx-200-200.png",pptx:"/file-placeholder/pptx-200-200.png",jpg:"/file-placeholder/jpeg-200-200.png",jpeg:"/file-placeholder/jpeg-200-200.png",png:"/file-placeholder/png-200-200.png",gif:"/file-placeholder/gif-200-200.png",webp:"/file-placeholder/png-200-200.png",bmp:"/file-placeholder/png-200-200.png",svg:"/file-placeholder/svg-200-200.png",default:"/file-placeholder/unknown-200-200.png"},eI=new Set(["application/pdf","application/xhtml+xml","application/xml","application/xslt+xml","image/svg+xml","text/html","text/xml"]),eA=new Set(["htm","html","pdf","svg","svgz","xht","xhtml","xml","xsl","xslt"]),eT=function(e){return e.split("?")[0].split("#")[0]},eR=function(e){if(!e)return"";var t=eT(e),n=t.lastIndexOf(".");return -1!==n?t.slice(n+1).toLowerCase():""},eD={aac:"audio/aac",avi:"video/x-msvideo",bmp:"image/bmp",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",flv:"video/x-flv",gif:"image/gif",jpeg:"image/jpeg",jpg:"image/jpeg",json:"application/json",mkv:"video/x-matroska",mov:"video/quicktime",mp3:"audio/mpeg",mp4:"video/mp4",odt:"application/vnd.oasis.opendocument.text",ogg:"audio/ogg",pdf:"application/pdf",png:"image/png",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",svg:"image/svg+xml",txt:"text/plain",wav:"audio/wav",webp:"image/webp",wmv:"video/x-ms-wmv",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};function e_(e,t){return!!e&&(e.originFileObj?el()(e.type,t):e.mimetype?el()(e.mimetype,t):!!e.url&&el()(eD[eR(e.url)]||"",t))}var eM=function(e){if(!e)return"";var t=eT(e),n=t.lastIndexOf("/"),r=-1!==n?t.slice(n+1):t;try{return decodeURIComponent(r)}catch(e){return r}},eU=function(e,t){if(e&&(void 0===e?"undefined":ev(e))==="object"){if(e.extname)return String(e.extname).replace(/^\./,"").toLowerCase();var n=eR(e.name||e.filename||e.title);if(n)return n}return eR(t)},eB=function(e,t){var n=(null==e?void 0:e.mimetype)||(null==e?void 0:e.type);if("string"==typeof n&&eI.has(n.toLowerCase()))return!0;var r=eU(e,t);return eA.has(r)},eq=function(e,t){var n=(null==e?void 0:e.mimetype)||(null==e?void 0:e.type);return"string"==typeof n&&"application/pdf"===n.toLowerCase()||"pdf"===eU(e,t)},ez=function(e){if(!e||"u"<typeof window)return!0;try{return new URL(e,window.location.href).origin===window.location.origin}catch(e){return!0}},eL=function(e,t){var n=eM(t||ek(e));return e&&"string"!=typeof e&&(e.name||e.filename||e.title)||n},eN=function(e,t){var n=t||ek(e),r=eL(e,n),o=eU(e,n);return r&&o&&!r.toLowerCase().endsWith(".".concat(o))&&(r="".concat(r,".").concat(o)),"".concat(Date.now(),"_").concat(r||"file")},eK=function(e,t){var n;return n=eF[eU(e,t)]||eF.default,"".concat(ej.replace(/\/$/,""),"/").concat(n.replace(/^\//,""))},eG=function(e){var t,n=eE(e),r=eC(n);if(eB(n,r))return eK(n,r);var o=(null!=(t=eP.getTypeByFile(n))?t:{}).getThumbnailURL,i=null==o?void 0:o(n);return i||(e_(n,"image/*")?"":eK(n,r))},eV=function(e){var t=e.index,n=e.list,r=e.onSwitchIndex,o=e.onDownload,a=e.file,l="number"==typeof t&&!!r&&t>0,c="number"==typeof t&&!!r&&t<n.length-1;return i().createElement(E.Space,{size:14,style:{fontSize:"20px"}},i().createElement(A.LeftOutlined,{style:{cursor:l?"pointer":"not-allowed"},disabled:!l,onClick:function(){return l&&(null==r?void 0:r(t-1))}}),i().createElement(A.RightOutlined,{style:{cursor:c?"pointer":"not-allowed"},disabled:!c,onClick:function(){return c&&(null==r?void 0:r(t+1))}}),i().createElement(A.DownloadOutlined,{onClick:function(){return o(a)}}))},eW=function(e){return function(t){var n=t.open,r=t.onOpenChange,o=t.onClose,a=t.file;if("boolean"!=typeof n)return i().createElement(e,t);var l=eL(a,ek(a));return i().createElement(E.Modal,{open:n,title:l,onCancel:function(){null==r||r(!1),null==o||o()},footer:eV(t),width:"90vw",centered:!0},i().createElement("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"80vh",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},i().createElement(e,t)))}},e$=function(e){var t=ek(e.file);return t?i().createElement("iframe",{src:t,width:"100%",height:"100%",style:{border:"none"}}):null},eY=null,eZ=function(e){return e.endsWith("/")?e:"".concat(e,"/")},eH=function(e){var t=null==e?void 0:e.__webpack_public_path__;if(t)return eZ(t);var n=eZ((null==e?void 0:e.__nocobase_public_path__)||"/"),r="string"==typeof(null==e?void 0:e.__nocobase_modern_client_prefix__)?e.__nocobase_modern_client_prefix__.replace(/^\/+|\/+$/g,""):"";return r?n.replace(new RegExp("/".concat(r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"/$")),"/"):n},eX=function(){var e=eH("u"<typeof window?void 0:window);return"".concat(e,"static/plugins/@nocobase/plugin-file-manager/dist/client/pdfjs/")},eQ=function(){var e=eX();return{cMapPacked:!0,cMapUrl:"".concat(e,"cmaps/"),standardFontDataUrl:"".concat(e,"standard_fonts/")}},eJ=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(e,n,r){var o,i,a;return ep(this,t),i=t,a=[n],i=em(i),ed(o=function(e,t){if(t&&("object"===ev(t)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,ex()?Reflect.construct(i,a||[],em(this).constructor):i.apply(this,a)),"code",void 0),ed(o,"cause",void 0),o.name="PdfPreviewError",o.code=e,o.cause=r,o}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&eg(t,e),t}(ew(Error)),e0=function(e){return(null!=eJ&&"u">typeof Symbol&&eJ[Symbol.hasInstance]?!!eJ[Symbol.hasInstance](e):e instanceof eJ)?e.code:"document"},e1=(0,er.css)(eS(),1.4),e2={resources:"PDF preview resources failed to load. Please refresh the page and check whether plugin static files are deployed correctly.",file:"PDF preview failed to load the file. If the file is stored on